From bd0e5ae1633b56559c422c623350ed4f35342acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 26 Oct 2018 15:12:24 +0800 Subject: [PATCH] fix #2672, use APP_TYPE judge add ga --- config/config.js | 81 +++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/config/config.js b/config/config.js index 9b500b29..a7daaeed 100644 --- a/config/config.js +++ b/config/config.js @@ -4,46 +4,51 @@ import pageRoutes from './router.config'; import webpackPlugin from './plugin.config'; import defaultSettings from '../src/defaultSettings'; -export default { - // add for transfer to umi - plugins: [ - [ - 'umi-plugin-react', - { - antd: true, - dva: { - hmr: true, - }, - targets: { - ie: 11, - }, - locale: { - enable: true, // default false - default: 'zh-CN', // default zh-CN - baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default - }, - dynamicImport: { - loadingComponent: './components/PageLoading/index', - }, - ...(!process.env.TEST && os.platform() === 'darwin' - ? { - dll: { - include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], - exclude: ['@babel/runtime'], - }, - hardSource: true, - } - : {}), +const plugins = [ + [ + 'umi-plugin-react', + { + antd: true, + dva: { + hmr: true, + }, + targets: { + ie: 11, }, - ], - [ - 'umi-plugin-ga', - { - code: 'UA-72788897-6', - judge: () => process.env.APP_TYPE === 'site', + locale: { + enable: true, // default false + default: 'zh-CN', // default zh-CN + baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default }, - ], + dynamicImport: { + loadingComponent: './components/PageLoading/index', + }, + ...(!process.env.TEST && os.platform() === 'darwin' + ? { + dll: { + include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], + exclude: ['@babel/runtime'], + }, + hardSource: true, + } + : {}), + }, ], +]; + +// judge add ga +if (process.env.APP_TYPE === 'site') { + plugins.push([ + 'umi-plugin-ga', + { + code: 'UA-72788897-6', + }, + ]); +} + +export default { + // add for transfer to umi + plugins, targets: { ie: 11, }, @@ -95,7 +100,7 @@ export default { }, }, manifest: { - basePath:"/" + basePath: '/', }, chainWebpack: webpackPlugin,