您的位置:首页 > Web前端 > Webpack

webpack速查

2015-10-03 17:36 465 查看
1.到官网下载nodejs:http://nodejs.cn/

2.根据http://jingyan.baidu.com/article/b0b63dbfca599a4a483070a5.html安装nodejs

3.npm现集成在nodejs中,所以无需下载安装

4.建立一个项目,从终端到项目的根目录下,执行npm install webpack -g,npm install webpack –save-dev

5.执行npm init,根据提示填写项目信息

6.根目录下新建index.html,main.js,webpack.config.js

7.在webpack.config.js中写上

module.exports = {
entry: './main.js',
output: {
path: __dirname,
filename: 'bundle.js'
}
}


8.执行webpack

9.在index.html中引入bundle.js

<script src="./bundle.js"></script>


10.执行npm install webpack-dev-server -g

11.执行webpack-dev-server

12.浏览器打开http://localhost:8080
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: