【问题标题】:How to use .babelrc plug-in options in webpack.config.js如何在 webpack.config.js 中使用 .babelrc 插件选项
【发布时间】:2017-03-06 15:24:20
【问题描述】:

.babelrc上的插件选项如下:

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

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

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 上的这个修改有效:

plugins: [
        'react-html-attrs', 
        'transform-decorators-legacy', 
        'transform-class-properties', 
        ['transform-runtime',{"polyfill": false, "regenerator": true}]
]

【问题讨论】:

    标签: javascript webpack babeljs


    【解决方案1】:

    看起来webpack.config.js 上的这个修改有效:

    plugins: [
            'react-html-attrs', 
            'transform-decorators-legacy', 
            'transform-class-properties', 
            ['transform-runtime',{"polyfill": false, "regenerator": true}]
    ]
    

    【讨论】:

      猜你喜欢
      • 2017-08-29
      • 2015-11-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多