Skip to content

Commit fd70600

Browse files
committed
chore: add dark css build
1 parent a6ec8cb commit fd70600

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"pre-publish": "node ./scripts/prepub",
4141
"prettier": "prettier -c --write '**/*'",
4242
"pretty-quick": "pretty-quick",
43-
"dist": "node antd-tools/cli/run.js dist",
43+
"dist": "node --max_old_space_size=6144 antd-tools/cli/run.js dist",
4444
"lint": "eslint -c ./.eslintrc --fix --ext .jsx,.js,.vue,.ts,.tsx ./components",
4545
"lint:site": "eslint -c ./.eslintrc --fix --ext .jsx,.js,.vue ./antdv-demo",
4646
"lint:docs": "eslint -c ./.eslintrc --fix --ext .jsx,.js,.vue,.md ./antdv-demo/docs/**/demo/**",
@@ -133,6 +133,7 @@
133133
"gulp-typescript": "^6.0.0-alpha.1",
134134
"html-webpack-plugin": "^3.2.0",
135135
"husky": "^4.0.0",
136+
"ignore-emit-webpack-plugin": "^2.0.6",
136137
"istanbul-instrumenter-loader": "^3.0.0",
137138
"jest": "^26.0.0",
138139
"jest-environment-jsdom-fifteen": "^1.0.2",

webpack.build.conf.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// This config is for building dist files
22
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
3+
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
4+
const darkVars = require('./scripts/dark-vars');
35
const { webpack } = getWebpackConfig;
46
// noParse still leave `require('./locale' + name)` in dist files
57
// ignore is better
@@ -36,4 +38,34 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
3638
});
3739
}
3840

39-
module.exports = webpackConfig;
41+
const webpackDarkConfig = getWebpackConfig(false);
42+
43+
webpackDarkConfig.forEach(config => {
44+
ignoreMomentLocale(config);
45+
externalMoment(config);
46+
47+
// rename default entry to ${theme} entry
48+
Object.keys(config.entry).forEach(entryName => {
49+
config.entry[entryName.replace('antd', `antd.dark`)] = config.entry[entryName];
50+
delete config.entry[entryName];
51+
});
52+
53+
// apply ${theme} less variables
54+
config.module.rules.forEach(rule => {
55+
// filter less rule
56+
if (rule.test instanceof RegExp && rule.test.test('.less')) {
57+
const lessRule = rule.use[rule.use.length - 1];
58+
if (lessRule.options.lessOptions) {
59+
lessRule.options.lessOptions.modifyVars = darkVars;
60+
} else {
61+
lessRule.options.modifyVars = darkVars;
62+
}
63+
}
64+
});
65+
66+
const themeReg = new RegExp(`dark(.min)?\\.js(\\.map)?`);
67+
// ignore emit ${theme} entry js & js.map file
68+
config.plugins.push(new IgnoreEmitPlugin(themeReg));
69+
});
70+
71+
module.exports = webpackConfig.concat(webpackDarkConfig);

0 commit comments

Comments
 (0)