From 5cdcfb90a0aae29af4ceac4ce39cb17e8d972397 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 22 Nov 2016 20:07:30 +0800 Subject: [PATCH 1/2] fix custom @icon-url variable --- package.json | 3 +-- src/custom.less | 4 +++- src/global.less | 6 ++++++ src/index.js | 2 +- src/index.less | 11 ----------- theme.js | 3 --- webpack.config.js | 20 +++++++++++++++++--- 7 files changed, 28 insertions(+), 21 deletions(-) create mode 100755 src/global.less delete mode 100755 src/index.less diff --git a/package.json b/package.json index c4d345e..6d383c2 100755 --- a/package.json +++ b/package.json @@ -36,6 +36,5 @@ "start": "dora --plugins \"proxy,webpack,webpack-hmr,browser-history?index=/src/index.html\"", "lint": "eslint --fix --ext .js,.jsx .", "build": "atool-build" - }, - "theme": "./theme.js" + } } diff --git a/src/custom.less b/src/custom.less index 0f4b98e..2985ad4 100644 --- a/src/custom.less +++ b/src/custom.less @@ -1,2 +1,4 @@ - +@primary-color: #1DA57A; +@link-color: #1DA57A; +@border-radius-base: 2px; @icon-url: "/assets/fonts/iconfont/iconfont"; diff --git a/src/global.less b/src/global.less new file mode 100755 index 0000000..b56cecc --- /dev/null +++ b/src/global.less @@ -0,0 +1,6 @@ +@import '~antd/dist/antd.less'; +@import 'custom.less'; + +html, body, #root { + height: 100%; +} diff --git a/src/index.js b/src/index.js index 9341f3e..d66234e 100755 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import './index.html'; -import './index.less'; +import './global.less'; import dva from 'dva'; import createLoading from 'dva-loading'; import {browserHistory} from 'dva/router'; diff --git a/src/index.less b/src/index.less deleted file mode 100755 index 0b41d3d..0000000 --- a/src/index.less +++ /dev/null @@ -1,11 +0,0 @@ - -:global { - html, body, #root { - height: 100%; - } -} - -// @import "~antd/lib/style/themes/default.less"; -// @import "custom.less"; -// @import "~antd/lib/style/core/index.less"; -// @import "~antd/lib/style/components.less"; diff --git a/theme.js b/theme.js index 9bc9012..b1172fd 100644 --- a/theme.js +++ b/theme.js @@ -1,11 +1,8 @@ - module.exports = () => { - return { '@primary-color': '#1DA57A', '@link-color': '#1DA57A', '@border-radius-base': '2px', '@icon-url': '/assets/fonts/iconfont/iconfont' }; - }; diff --git a/webpack.config.js b/webpack.config.js index abe5a03..eaab5fa 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,7 +7,6 @@ module.exports = function (webpackConfig, env) { webpackConfig.babel.plugins.push('transform-runtime'); webpackConfig.babel.plugins.push(['import', { libraryName: 'antd', - style: 'css' // if true, use less }]); // Enable hmr for development. @@ -15,15 +14,30 @@ module.exports = function (webpackConfig, env) { webpackConfig.babel.plugins.push('dva-hmr'); } + // CSS Modules Support. // Parse all less files as css module. - webpackConfig.module.loaders.forEach(function (loader, index) { + console.log(webpackConfig.module.loaders, '!!!!!!!') + + webpackConfig.module.loaders.forEach(function(loader, index) { if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.less$') > -1) { - loader.test = /\.dont\.exist\.file/; + loader.include = [/node_modules/, /global\.less/]; // treat global.less as non-css-modules less file + loader.test = /\.less$/; } if (loader.test.toString() === '/\\.module\\.less$/') { + loader.exclude = [/node_modules/, /global\.less/]; // treat global.less as non-css-modules less file loader.test = /\.less$/; } + if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.css$') > -1) { + loader.include = /node_modules/; + loader.test = /\.css$/; + } + if (loader.test.toString() === '/\\.module\\.css$/') { + loader.exclude = /node_modules/; + loader.test = /\.css$/; + } }); + console.log(webpackConfig.module.loaders) + return webpackConfig; }; From 7e47f9b3596c07226409e081bb77e68f7552e842 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 22 Nov 2016 20:19:50 +0800 Subject: [PATCH 2/2] remove console --- webpack.config.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index eaab5fa..588a3a9 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,8 +16,6 @@ module.exports = function (webpackConfig, env) { // CSS Modules Support. // Parse all less files as css module. - console.log(webpackConfig.module.loaders, '!!!!!!!') - webpackConfig.module.loaders.forEach(function(loader, index) { if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.less$') > -1) { loader.include = [/node_modules/, /global\.less/]; // treat global.less as non-css-modules less file @@ -37,7 +35,5 @@ module.exports = function (webpackConfig, env) { } }); - console.log(webpackConfig.module.loaders) - return webpackConfig; };