- npm init 将当前文件夹变为npm环境,生成package.json文件
- npm install babel babel-core babel-loader webpack,安装所以组件
- 配置webpack.config.js,代码如下:
var webpack = require('webpack');
module.export = {
entry: {
'app': './src/app.js'
},
output: {
path: __dirname + '/output/',
filename: '[name].bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
}
}