diff --git a/index-dark.js b/index-dark.js new file mode 100644 index 0000000000..3ff2a13374 --- /dev/null +++ b/index-dark.js @@ -0,0 +1,2 @@ +require('./components/style/dark.less'); +require('./index'); diff --git a/package.json b/package.json index f90a4bcb86..e9330c42dd 100644 --- a/package.json +++ b/package.json @@ -196,6 +196,7 @@ "glob": "^7.1.4", "http-server": "^0.12.0", "husky": "^3.0.2", + "ignore-emit-webpack-plugin": "^2.0.2", "immutability-helper": "^3.0.0", "intersection-observer": "^0.7.0", "jest": "^24.8.0", diff --git a/webpack.config.js b/webpack.config.js index 98a98f795c..afb3e5af43 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ // This config is for building dist files const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig'); const PacktrackerPlugin = require('@packtracker/webpack-plugin'); +const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin'); const { webpack } = getWebpackConfig; @@ -21,6 +22,16 @@ function addLocales(webpackConfig) { webpackConfig.output.filename = '[name].js'; } +function addDarkTheme(webpackConfig) { + let packageName = 'antd-dark'; + if (webpackConfig.entry['antd.min']) { + packageName += '.min'; + } + webpackConfig.entry[packageName] = './index-dark.js'; + webpackConfig.output.filename = '[name].js'; + webpackConfig.plugins.push(new IgnoreEmitPlugin(/dark(.min)?\.js(\.map)?$/)); +} + function externalMoment(config) { config.externals.moment = { root: 'moment', @@ -36,6 +47,7 @@ if (process.env.RUN_ENV === 'PRODUCTION') { ignoreMomentLocale(config); externalMoment(config); addLocales(config); + addDarkTheme(config); // skip codesandbox ci if (!process.env.CSB_REPO) { // https://docs.packtracker.io/uploading-your-webpack-stats/webpack-plugin