diff --git a/config/config.js b/config/config.js index 61fe8e2b525d302c18065798fbdc975d86667073..9b78b7e651e7e4ca1d313746fe26712ca055150b 100644 --- a/config/config.js +++ b/config/config.js @@ -6,6 +6,7 @@ import defaultSettings from '../src/defaultSettings'; import slash from 'slash2'; const { pwa, primaryColor } = defaultSettings; +const { NODE_ENV, APP_TYPE, TEST } = process.env; const plugins = [ [ @@ -32,7 +33,7 @@ const plugins = [ }, } : {}, - ...(!process.env.TEST && os.platform() === 'darwin' + ...(!TEST && os.platform() === 'darwin' ? { dll: { include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], @@ -47,7 +48,7 @@ const plugins = [ // 针对 preview.pro.ant.design 的 GA 统计代码 // 业务上不需要这个 -if (process.env.APP_TYPE === 'site') { +if (APP_TYPE === 'site') { plugins.push([ 'umi-plugin-ga', { @@ -60,7 +61,7 @@ export default { // add for transfer to umi plugins, define: { - APP_TYPE: process.env.APP_TYPE || '', + APP_TYPE: APP_TYPE || '', }, treeShaking: true, targets: { @@ -75,6 +76,10 @@ export default { }, externals: { '@antv/data-set': 'DataSet', + // if is production externals react react-dom and bizcharts + ...(NODE_ENV === 'production' + ? { react: 'React', 'react-dom': 'ReactDOM', bizcharts: 'BizCharts' } + : {}), }, // proxy: { // '/server/api/': { diff --git a/src/pages/document.ejs b/src/pages/document.ejs index 36be3f61a731a3f252f7f0ba8b137a37b56cb996..847536651855e59f5b4c7090aa00577df846f7ee 100644 --- a/src/pages/document.ejs +++ b/src/pages/document.ejs @@ -9,7 +9,12 @@ /> Ant Design Pro - + <% if(context.env === 'production') { %> + + + + <% }%> +