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