Browse Source

chore: fix site build (#37773)

* fix: some try

* chore: revert sideEffect

* chore: code clean
pull/37786/head
MadCcc 2 years ago
committed by GitHub
parent
commit
1331b84355
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      package.json
  2. 25
      site/antd.js
  3. 46
      site/bisheng.config.js
  4. 2
      site/theme/template/Content/ComponentOverview.less
  5. 2
      site/theme/template/Home/Banner/Background.less
  6. 2
      site/theme/template/Layout/Header/SearchBar.less

4
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",

25
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');

46
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 = {

2
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;

2
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;

2
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';

Loading…
Cancel
Save