diff --git a/config/config.ts b/config/config.ts index c84b80704d6a5ff917b6f567cbc45e44e6bd8b5e..dc4b7175b2e4933acd84509ac70b361ebca6862c 100644 --- a/config/config.ts +++ b/config/config.ts @@ -7,7 +7,7 @@ import webpackPlugin from './plugin.config'; const { pwa, primaryColor } = defaultSettings; // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 -const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST } = process.env; +const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST, NODE_ENV } = process.env; const plugins: IPlugin[] = [ [ @@ -67,6 +67,17 @@ if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { }, ]); } +const uglifyJSOptions = NODE_ENV === 'production' + ? { + uglifyOptions: { + // remove console.* except console.error + compress: { + drop_console: true, + pure_funcs: [ 'console.error' ], + }, + }, + } + : {}; export default { // add for transfer to umi @@ -145,5 +156,6 @@ export default { manifest: { basePath: '/', }, + uglifyJSOptions, chainWebpack: webpackPlugin, } as IConfig; diff --git a/tslint.yml b/tslint.yml index e425aa18564e0f05e514885f97006f40b91b48a5..7f4cc04dfa53ecbfe2b3be750cf578a57a21ee63 100644 --- a/tslint.yml +++ b/tslint.yml @@ -20,15 +20,6 @@ rules: no-bitwise: true no-conditional-assignment: true no-consecutive-blank-lines: true - no-console: - - true - - debug - - info - - log - - time - - timeEnd - - trace - - warn no-construct: true no-debugger: true no-duplicate-variable: true