webpack转换ES6=>ES2015

  1. npm init 将当前文件夹变为npm环境,生成package.json文件
  2. npm install babel babel-core babel-loader webpack,安装所以组件
  3. 配置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']
                    }
                }
            ]
        }
    }   

你可能感兴趣的:(webpack转换ES6=>ES2015)