diff --git a/package.json b/package.json index 1c7bfd537f..d04ee43024 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,9 @@ "dist", "es" ], - "sideEffects": false, + "sideEffects": [ + "*.less" + ], "main": "dist/antd.js", "module": "es/index.js", "unpkg": "dist/antd.min.js", diff --git a/site/antd.js b/site/antd.js index d831021e6f..c2ebdc9a4a 100644 --- a/site/antd.js +++ b/site/antd.js @@ -1,28 +1,3 @@ -/* eslint no-console:0 */ -function pascalCase(name) { - return name.charAt(0).toUpperCase() + name.slice(1).replace(/-(\w)/g, (m, n) => n.toUpperCase()); -} - -// Import all the component less file. -// This is mostly like index.js but we do not need root `themes/index` -const req = require.context('../components', true, /^\.\/[^_][\w-]+\/style\/index\.less$/); - -req.keys().forEach(mod => { - let v = req(mod); - if (v && v.default) { - v = v.default; - } - const match = mod.match(/^\.\/([^_][\w-]+)\/index\.less$/); - if (match && match[1]) { - if (match[1] === 'message' || match[1] === 'notification') { - // message & notification should not be capitalized - exports[match[1]] = v; - } else { - exports[pascalCase(match[1])] = v; - } - } -}); - // Need import for the additional core style exports.styleCore = require('../components/style/reset.css'); diff --git a/site/bisheng.config.js b/site/bisheng.config.js index 730e00df6c..2e30880a74 100644 --- a/site/bisheng.config.js +++ b/site/bisheng.config.js @@ -10,7 +10,6 @@ const themeConfig = require('./themeConfig'); const { webpack } = getWebpackConfig; const isDev = process.env.NODE_ENV === 'development'; -const { ANT_THEME, DEV_THEME } = process.env; function alertBabelConfig(rules) { rules.forEach(rule => { @@ -42,7 +41,7 @@ module.exports = { 'components/form/v3': ['components/form/v3.zh-CN.md', 'components/form/v3.en-US.md'], 'docs/resources': ['./docs/resources.zh-CN.md', './docs/resources.en-US.md'], }, - theme: ANT_THEME ? './site/theme/index-css-only.js' : './site/theme', + theme: './site/theme', htmlTemplate: './site/theme/static/template.html', themeConfig, filePathMapper(filePath) { @@ -63,7 +62,7 @@ module.exports = { lessConfig: { javascriptEnabled: true, modifyVars: { - 'root-entry-name': ANT_THEME || DEV_THEME || 'variable', + 'root-entry-name': 'variable', }, }, webpackConfig(config) { @@ -131,47 +130,6 @@ module.exports = { config.mode = 'development'; } - if (ANT_THEME) { - config.mode = 'development'; - config.plugins.forEach(plugin => { - if (plugin?.options?.filename?.includes?.('.css')) { - delete plugin.options.chunkFilename; - plugin.options.filename = `${ANT_THEME}.css`; - } - }); - - // Remove preset target - config.module.rules.forEach(rule => { - if (rule.options?.presets?.[1]?.[0]?.includes('preset-env')) { - delete rule.options.presets[1][1]; - delete rule.options.plugins; - } - }); - - config.optimization.minimize = false; - delete config.optimization.minimizer; - - config.externals = [ - /^rc-.*/, - /^react.*/, - /^@ant-design\/.*/, - /^@babel\/.*/, - /^@algolia\/.*/, - /^@docsearch\/.*/, - /autocomplete.js/, - /docsearch.js/, - /.*\.md/, - /lodash/, - /jquery/, - /dayjs/, - /core-js/, - /jsonml/, - /ramda/, - /tinycolor/, - /bisheng-plugin/, - ]; - } - // Split chunks if (config.mode === 'production') { config.optimization.splitChunks = { diff --git a/site/theme/template/Content/ComponentOverview.less b/site/theme/template/Content/ComponentOverview.less index 1f22f8b53b..8d81d0d1e0 100644 --- a/site/theme/template/Content/ComponentOverview.less +++ b/site/theme/template/Content/ComponentOverview.less @@ -1,4 +1,4 @@ -@import '../../style/themes/index.less'; +@import (reference) '../../style/themes/index.less'; .components-overview { padding: 0; diff --git a/site/theme/template/Home/Banner/Background.less b/site/theme/template/Home/Banner/Background.less index 861138f280..a81991f6bb 100644 --- a/site/theme/template/Home/Banner/Background.less +++ b/site/theme/template/Home/Banner/Background.less @@ -1,4 +1,4 @@ -@import '../../../style/themes/index.less'; +@import (reference) '../../../style/themes/index.less'; .home-banner-background { position: absolute; diff --git a/site/theme/template/Layout/Header/SearchBar.less b/site/theme/template/Layout/Header/SearchBar.less index 2fb43ca903..4fdf646477 100644 --- a/site/theme/template/Layout/Header/SearchBar.less +++ b/site/theme/template/Layout/Header/SearchBar.less @@ -1,5 +1,5 @@ @import '../../../static/theme.less'; -@import '../../../style/themes/index.less'; +@import (reference) '../../../style/themes/index.less'; @import './index.less'; @import './DocSearch.less';