Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom @icon-url variable in less way #1

Merged
merged 2 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 3 additions & 1 deletion src/custom.less
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

@primary-color: #1DA57A;
@link-color: #1DA57A;
@border-radius-base: 2px;
@icon-url: "/assets/fonts/iconfont/iconfont";
6 changes: 6 additions & 0 deletions src/global.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '~antd/dist/antd.less';
@import 'custom.less';

html, body, #root {
height: 100%;
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
11 changes: 0 additions & 11 deletions src/index.less

This file was deleted.

3 changes: 0 additions & 3 deletions theme.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

module.exports = () => {

return {
'@primary-color': '#1DA57A',
'@link-color': '#1DA57A',
'@border-radius-base': '2px',
'@icon-url': '/assets/fonts/iconfont/iconfont'
};

};
16 changes: 13 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,32 @@ 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.
if (env === 'development') {
webpackConfig.babel.plugins.push('dva-hmr');
}

// CSS Modules Support.
// Parse all less files as css module.
webpackConfig.module.loaders.forEach(function (loader, index) {
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$/;
}
});

return webpackConfig;
Expand Down