From 65e822ea5451a9e22d7f7435ba8cc1c9a9a4ad03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Wed, 13 Feb 2019 18:10:56 +0800 Subject: [PATCH] feat: Officially traded will use cdn to optimize bizchart (#3535) --- config/config.js | 11 ++++++++--- src/pages/document.ejs | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config/config.js b/config/config.js index 61fe8e2b..9b78b7e6 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 36be3f61..84753665 100644 --- a/src/pages/document.ejs +++ b/src/pages/document.ejs @@ -9,7 +9,12 @@ /> Ant Design Pro - + <% if(context.env === 'production') { %> + + + + <% }%> + -- GitLab