生产模式下的webpack 4无法编译打字稿

时间:2018-10-24 12:26:35

标签: typescript webpack

readme之后从Webpack 3迁移到Webpack 4之后

我的打字稿应用程序将webpack设置为mode: production

时出现复杂错误

错误:

Uncaught TypeError: Object(...) is not a function
    at Object.822 (Tag.tsx:65)

哪个映射到此行:

withExpertFeed(({removeAttribute}) => ({removeAttribute})),

此webpack配置有效:

module.exports = merge(common(), {
    devtool: 'source-map',
    mode: 'development', // Set to development
    plugins: [
        }),
        new CopyWebpackPlugin([{
            from: 'public',
        }, ]),
        new ForkTsCheckerWebpackPlugin({
            checkSyntacticErrors: false,
            tsconfig: '../web-tsconfig.json',
        }),
        new HtmlWebpackPlugin({
            inject: true,
            template: path.resolve(__dirname, 'public/index.html'),
            filename: 'index.html',
            minify: {
                removeComments: true,
                collapseWhitespace: true,
                removeRedundantAttributes: true,
                useShortDoctype: true,
                removeEmptyAttributes: true,
                removeStyleLinkTypeAttributes: true,
                keepClosingSlash: true,
                minifyJS: true,
                minifyCSS: true,
                minifyURLs: true,
            },
        }),
    ],
    optimization: {
        minimizer: [
            new UglifyJSPlugin({
                uglifyOptions: {
                    output: {
                        ascii_only: true,
                    },
                },
                parallel: true,
                cache: true,
                sourceMap: true
            }),
        ]
    }
});

设置mode: production时,相同的webpack配置失败,并出现上述错误

0 个答案:

没有答案
相关问题