From a73589a5400b4acf0571f3def1185fc04121ab6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?chencheng=20=28=E4=BA=91=E8=B0=A6=29?= Date: Thu, 12 Apr 2018 12:28:32 +0800 Subject: [PATCH] fix(umi-buil-dev): global.scss don't work (#319) --- packages/umi-build-dev/src/getWebpackConfig.js | 6 +----- packages/umi-build-dev/src/plugins/global-css.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/umi-build-dev/src/getWebpackConfig.js b/packages/umi-build-dev/src/getWebpackConfig.js index cf43a490d14d..b3a0cf120942 100644 --- a/packages/umi-build-dev/src/getWebpackConfig.js +++ b/packages/umi-build-dev/src/getWebpackConfig.js @@ -141,11 +141,7 @@ export default function(service = {}) { ...(webpackRCConfig.extraResolveModules || []), ...(extraResolveModules || []), ], - cssModulesExcludes: [ - ...(webpackRCConfig.cssModulesExcludes || []), - join(paths.absSrcPath, 'global.css'), - join(paths.absSrcPath, 'global.less'), - ], + cssModulesExcludes: [...(webpackRCConfig.cssModulesExcludes || [])], define: { // 禁用 antd-mobile 升级提醒 'process.env.DISABLE_ANTD_MOBILE_UPGRADE': true, diff --git a/packages/umi-build-dev/src/plugins/global-css.js b/packages/umi-build-dev/src/plugins/global-css.js index 68fa3960bda0..d331a6e34fa7 100644 --- a/packages/umi-build-dev/src/plugins/global-css.js +++ b/packages/umi-build-dev/src/plugins/global-css.js @@ -34,4 +34,17 @@ ${cssImports.join('\\r\\n')} join(paths.absSrcPath, 'global.scss'), ]; }); + + api.register('modifyAFWebpackOpts', ({ memo }) => { + return { + ...memo, + cssModulesExcludes: [ + ...(memo.cssModulesExcludes || []), + join(paths.absSrcPath, 'global.css'), + join(paths.absSrcPath, 'global.less'), + join(paths.absSrcPath, 'global.scss'), + join(paths.absSrcPath, 'global.sass'), + ], + }; + }); }