详解webpack es6 to es5支持配置

webpackvuees 2017-05-04

1. 安装webpack

npm install webpack --save-dev

2. 安装babel  实现 ES6 到 ES5

npm install --save-dev babel-core babel-preset-es2015

3.安装 babel-loader

npm install --save-dev babel-loader

webpack.config.js完整配置

module.exports = {
  entry: './src/js/app.js',
  output: {
    path: './dest',
    filename: 'app.bundle.js',
  },
  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'babel-loader',
    }]
  },
  babel: {
   presets: ['es2015']
  },
}

相关推荐