Skip to content

Commit

Permalink
docs: site build script update (ant-design#32984)
Browse files Browse the repository at this point in the history
* chore: rm color-less

* refactor: MV theme to variable

* docs: fix header

* chore: clean up

* chore: enable esbuild
  • Loading branch information
zombieJ authored Nov 23, 2021
1 parent 37442ae commit b926c53
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 100 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"pretest": "npm run version",
"predist": "npm run version",
"presite": "npm run version",
"color-less": "node ./scripts/generate-color-less",
"compile": "npm run clean && antd-tools run compile",
"changelog": "node ./scripts/print-changelog",
"predeploy": "antd-tools run clean && npm run site && cp CNAME _site && npm run site:test",
Expand All @@ -84,10 +83,13 @@
"pretty-quick": "pretty-quick",
"pub": "npm run version && antd-tools run pub",
"prepublishOnly": "antd-tools run guard",
"site": "cross-env NODE_ICU_DATA=node_modules/full-icu ESBUILD=1 concurrently \"bisheng build --ssr -c ./site/bisheng.config.js\" \"npm run color-less\"",
"site:theme": "npm run site:theme-dark && npm run site:theme-compact",
"site:theme-dark": "cross-env ESBUILD=1 ANT_THEME=dark bisheng build --ssr -c ./site/bisheng.config.js",
"site:theme-compact": "cross-env ESBUILD=1 ANT_THEME=compact bisheng build --ssr -c ./site/bisheng.config.js",
"site": "npm run site:theme && cross-env NODE_ICU_DATA=node_modules/full-icu ESBUILD=1 concurrently \"bisheng build --ssr -c ./site/bisheng.config.js\"",
"sort": "npx sort-package-json",
"sort-api": "antd-tools run sort-api-table",
"start": "antd-tools run clean && cross-env NODE_ENV=development concurrently \"npm run color-less\" \"bisheng start -c ./site/bisheng.config.js\"",
"start": "antd-tools run clean && cross-env NODE_ENV=development concurrently \"bisheng start -c ./site/bisheng.config.js\"",
"test": "jest --config .jest.js --cache=false",
"test:update": "jest --config .jest.js --cache=false -u",
"test-all": "sh -e ./scripts/test-all.sh",
Expand Down Expand Up @@ -177,8 +179,6 @@
"@typescript-eslint/parser": "^5.0.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.0",
"antd-img-crop": "^3.1.1",
"antd-pro-merge-less": "^3.0.11",
"antd-theme-generator": "^1.2.3",
"argos-cli": "^0.3.0",
"array-move": "^4.0.0",
"babel-plugin-add-react-displayname": "^0.0.5",
Expand Down
50 changes: 0 additions & 50 deletions scripts/generate-color-less.js

This file was deleted.

16 changes: 14 additions & 2 deletions site/bisheng.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const themeConfig = require('./themeConfig');
const { webpack } = getWebpackConfig;

const isDev = process.env.NODE_ENV === 'development';
const { ANT_THEME } = process.env;

function alertBabelConfig(rules) {
rules.forEach(rule => {
Expand Down Expand Up @@ -36,7 +37,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: './site/theme',
theme: ANT_THEME ? './site/theme/index-css-only.js' : './site/theme',
htmlTemplate: './site/theme/static/template.html',
themeConfig,
filePathMapper(filePath) {
Expand All @@ -57,7 +58,7 @@ module.exports = {
lessConfig: {
javascriptEnabled: true,
modifyVars: {
'root-entry-name': 'variable',
'root-entry-name': ANT_THEME || 'variable',
},
},
webpackConfig(config) {
Expand Down Expand Up @@ -85,6 +86,7 @@ module.exports = {
react: require.resolve('react'),
};
} else if (process.env.ESBUILD) {
console.log('Enable ESBUILD');
// use esbuild
config.optimization.minimizer = [
new ESBuildMinifyPlugin({
Expand All @@ -110,6 +112,16 @@ module.exports = {

delete config.module.noParse;

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`;
}
});
}

return config;
},

Expand Down
19 changes: 19 additions & 0 deletions site/theme/index-css-only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* ZombieJ: This file is used for generate site theme css only. Which only provides dark.css and
* compact.css for theme switcher.
*/
const config = require('./index');

const homeTmpl = './template/Home/index';

const cloneConfig = {
...config,
};

cloneConfig.routes = {
path: '/',
component: './template/Layout/index',
indexRoute: { component: homeTmpl },
};

module.exports = cloneConfig;
2 changes: 0 additions & 2 deletions site/theme/static/header.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import (reference) '../../../components/style/themes/variable.less';

#header {
// ===================== Home Page =====================
&.home-header {
Expand Down
47 changes: 24 additions & 23 deletions site/theme/static/index.less
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
@import '../../../components/style/themes/index.less';

@import './reset.less';
@import '../../../components/style/themes/variable.less';
@import './common';
@import './header';
@import './footer';
@import './home';
@import './page-nav';
@import './markdown';
@import './design-doc';
@import './preview-img';
@import './toc';
@import './not-found';
@import './highlight';
@import './demo';
@import './colors';
@import './icons';
@import './icon-pic-searcher';
@import './mock-browser';
@import './motion';
@import './responsive';
@import './theme';
@import './docsearch';
@import './nprogress';
@import './contributors';
@import './common.less';
@import './header.less';
@import './footer.less';
@import './home.less';
@import './page-nav.less';
@import './markdown.less';
@import './design-doc.less';
@import './preview-img.less';
@import './toc.less';
@import './not-found.less';
@import './highlight.less';
@import './demo.less';
@import './colors.less';
@import './icons.less';
@import './icon-pic-searcher.less';
@import './mock-browser.less';
@import './motion.less';
@import './responsive.less';
@import './theme.less';
@import './docsearch.less';
@import './nprogress.less';
@import './contributors.less';
@import './dark.less';
@import './rtl.less';
2 changes: 0 additions & 2 deletions site/theme/static/responsive.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import (reference) '../../../components/style/themes/variable.less';

.nav-phone-icon {
position: absolute;
top: 25px;
Expand Down
1 change: 0 additions & 1 deletion site/theme/static/theme.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import (reference) '../../../components/style/themes/variable.less';
@import './colors.less';
@import './home.less';

Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Content/ComponentOverview.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../components/style/themes/variable.less';
@import (reference) '../../../../components/style/themes/index.less';

.components-overview {
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/Banner/Background.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';

.home-banner-background {
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/Banner/Logo.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';

.home-card-logo {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/Banner/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';

@home-color: #0170fe;

Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/DesignPage/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';

.design-card {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/MorePage.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../components/style/themes/variable.less';
@import (reference) '../../../../components/style/themes/index.less';

.more-card {
&:hover {
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/RecommendPage.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../components/style/themes/variable.less';
@import (reference) '../../../../components/style/themes/index.less';

.linear-gradient(@mid-pos, @end-pos) {
background: linear-gradient(
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Home/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../components/style/themes/variable.less';
@import (reference) '../../../../components/style/themes/index.less';

.home-container {
h1,
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Layout/Header/Github.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../../../static/theme.less';
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';

#github-btn {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Layout/Header/Logo.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../../../static/theme.less';
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';
@import './index.less';

#logo {
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Layout/Header/Navigation.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../../../static/theme.less';
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';
@import './index.less';

#nav {
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Layout/Header/SearchBar.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../../../static/theme.less';
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';
@import './index.less';
@import './DocSearch.less';

Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Layout/Header/index.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../../../static/theme.less';
@import (reference) '../../../../../components/style/themes/variable.less';
@import (reference) '../../../../../components/style/themes/index.less';

@header-height: 64px;
@menu-item-border: 2px;
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Resources/AffixTabs.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../components/style/themes/variable.less';
@import (reference) '../../../../components/style/themes/index.less';
@import './index.less';

.resource-affix-tabs {
Expand Down
2 changes: 1 addition & 1 deletion site/theme/template/Resources/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import (reference) '../../../../components/style/themes/variable.less';
@import (reference) '../../../../components/style/themes/index.less';

@ArticleMaxWidth: 1208px;
@resource-padding: 40px;
Expand Down

0 comments on commit b926c53

Please sign in to comment.