如何在webpack.config.js中使用.babelrc插件选项

时间:2017-03-06 15:24:20

标签: javascript webpack babeljs

.babelrc上插件的选项如下所示:

{
  "plugins": [
    ["transform-runtime", {
      "polyfill": false,
      "regenerator": true
    }]
  ]
}

由于我不想使用.babelrc,但我打算只使用webpack.config.js,我需要在{{1}添加"polyfill": false"regenerator": true个选项下面的文件,我该怎么做。

webpack.config.js

var webpack=require('webpack') module.exports = { //configuration context: __dirname + '/src/ui/', entry: './ui.js', module: { loaders: [{ // "test" is commonly used to match the file extension test: /\.jsx?$/, // "exclude" should be used to exclude exceptions exclude: /(node_modules|bower_components)/, loader: 'babel-loader', query: { presets: ['react', 'es2015', 'stage-0'], plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties', 'transform-runtime'], } }] }, output: { path: __dirname + '/src/public/js/', filename: 'ui.bundle.js' }, plugins: [], }; 上的此修改似乎有效:

webpack.config.js

0 个答案:

没有答案