NPM构建脚本在装饰器上失败(webpack,生产)

时间:2017-09-11 16:32:42

标签: javascript webpack

我正在运行一个npm构建脚本来捆绑和缩小我的代码:

"build": "rimraf dist && cross-env NODE_ENV=production webpack --config ./webpack.config.prod.js"

我不知道如何摆脱这个错误。只有在生成版本中获取它,才能在开发模式下正常工作。

Module build failed: SyntaxError: Decorators are not officially supported yet in 6.x pending a proposal update.
However, if you need to use them you can install the legacy decorators transform with...

我的.babelrc看起来像这样:

{
    "presets": ["react", "es2015", "stage-1", "stage-0"],
    "plugins": [
        [
            "babel-plugin-webpack-alias",
            {
                "config": "webpack.config.dev.js",
                "findConfig": true
            }
        ],
        ["transform-decorators-legacy"]
    ]
}

我的webpack.config.prod.js看起来像这样:

module: {
        loaders: [
            {
                test: /\.js?$/,
                include: [
                    path.join(__dirname, 'client'),
                    path.join(__dirname, 'server/shared'),
                ],
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    cacheDirectory: true,
                    presets: ['es2015', 'stage-0', 'stage-1', 'react'],
                    plugins: [
                        'transform-decorators-legacy',
                    ],
                },
            },
    }

0 个答案:

没有答案