YMFE / ykit

基于 Webpack 的灵活快速的打包工具,帮助稳定高效构建现代 JavaScript 应用。
https://ykit.ymfe.org/
Apache License 2.0
392 stars 56 forks source link

ykit关于发布到production环境react报错的问题 #43

Open shmilyzzd opened 5 years ago

shmilyzzd commented 5 years ago

使用ykit打包到production环境,前端页面报 React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production,但在ykit.config.js里面,发现production的配置没有问题,配置如下,麻烦问下如何解决,线上环境NODE_ENV为production modifyWebpackConfig: function (baseConfig) { var ENV_PARAMS = {}; switch (this.env) { case 'local': ENV_PARAMS = 'dev'; break; case 'dev': ENV_PARAMS = 'dev'; break; case 'prd': ENV_PARAMS = 'production'; break; default: }

honchy commented 5 years ago

@shmilyzzd ,这个是 ykit 没有默认开启移除 deadCode 功能。你可以手动开启,开启方式如下:

ykit.js


module.exports = {
    "plugins": [

    ],
    build: {
        uglifyjs: {
            squeeze: {
                dead_code: true
            }
        }
    },
    "config": {
        "export": [
            "...."
        ]
    }
};