diff --git a/.fatherrc.ts b/.fatherrc.ts index 8e2aa15b..4fc054c4 100644 --- a/.fatherrc.ts +++ b/.fatherrc.ts @@ -1,16 +1,12 @@ import { codecovWebpackPlugin } from '@codecov/webpack-plugin'; +import DuplicatePackageCheckerPlugin from '@madccc/duplicate-package-checker-webpack-plugin'; +import CircularDependencyPlugin from 'circular-dependency-plugin'; import { defineConfig } from 'father'; class CodecovWebpackPlugin { private options; constructor(options = {}) { - this.options = { - enableBundleAnalysis: true, - bundleName: 'webpack-bundle', - gitService: 'github', - disable: false, - ...options, - }; + this.options = options; } apply(compiler: any) { return codecovWebpackPlugin(this.options).apply(compiler); @@ -45,8 +41,8 @@ export default defineConfig({ '@ant-design/cssinjs': 'antdCssinjs', antd: 'antd', }, - chainWebpack: (memo) => { - if (process.env.NODE_ENV === 'production') { + chainWebpack: (memo, { env }) => { + if (env === 'production') { memo.plugin('codecov').use(CodecovWebpackPlugin, [ { enableBundleAnalysis: true, @@ -55,6 +51,17 @@ export default defineConfig({ gitService: 'github', }, ]); + memo.plugin('circular-dependency-checker').use(CircularDependencyPlugin, [ + { + failOnError: true, + }, + ]); + memo.plugin('duplicate-package-checker').use(DuplicatePackageCheckerPlugin, [ + { + verbose: true, + emitError: true, + }, + ]); } return memo; }, diff --git a/docs/react/contributing.en-US.md b/docs/react/contributing.en-US.md index 05faa630..87f7e612 100644 --- a/docs/react/contributing.en-US.md +++ b/docs/react/contributing.en-US.md @@ -88,17 +88,11 @@ runs the complete test suite. (Make sure the `NODE_ENV` environment variable is -### Compile - -compiles TypeScript code to the `lib` and `es` directory. - - - ### Build -creates UMD build of antd. +Build TypeScript code to the `lib` and `es` directory, creates UMD build of antdx. - + ## Development Tools diff --git a/docs/react/contributing.zh-CN.md b/docs/react/contributing.zh-CN.md index f86f920f..1260a9db 100644 --- a/docs/react/contributing.zh-CN.md +++ b/docs/react/contributing.zh-CN.md @@ -90,16 +90,10 @@ Ant Design 团队会关注所有的 pull request,我们会 review 以及合并 ### 编译 -编译 TypeScript 代码到 lib 和 es 目录。 +编译 TypeScript 代码到 lib 和 es 目录,UMD 版本到 dist 目录。 -### 构建 - -构建 antd 的 UMD 版本到 dist 目录。 - - - ## 配套开发工具 - CSS-in-JS 样式提示插件:https://marketplace.visualstudio.com/items?itemName=shezhangzhang.antd-design-token diff --git a/package.json b/package.json index cad512f3..a4cb6451 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "scripts": { "api-collection": "antd-tools run api-collection", "authors": "tsx scripts/generate-authors.ts", - "legacy_build": "npm run compile && NODE_OPTIONS='--max-old-space-size=4096' npm run dist", "changelog": "npm run lint:changelog && tsx scripts/print-changelog.ts", "check-commit": "tsx scripts/check-commit.ts", "clean": "antd-tools run clean && rm -rf es lib coverage locale dist report.html artifacts.zip oss-artifacts.zip", @@ -46,9 +45,6 @@ "predeploy": "npm run site && cp CNAME _site", "deploy": "gh-pages -d _site -b gh-pages -f", "predist": "npm run version && npm run token:statistic && npm run token:meta", - "legacy_dist": "antd-tools run dist", - "legacy_dist:esbuild": "ESBUILD=true npm run dist", - "legacy_dist:esbuild-no-dup-check": "ESBUILD=true NO_DUP_CHECK=true npm run dist", "format": "biome format --write .", "prelint": "dumi setup", "lint": "npm run version && npm run tsc && npm run lint:script && npm run lint:md && npm run lint:style && npm run lint:changelog", diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 763c7dfd..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,78 +0,0 @@ -/* eslint no-param-reassign: 0 */ -// This config is for building dist files -const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig'); -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); -const { EsbuildPlugin } = require('esbuild-loader'); -const CircularDependencyPlugin = require('circular-dependency-plugin'); -const DuplicatePackageCheckerPlugin = require('@madccc/duplicate-package-checker-webpack-plugin'); -const path = require('path'); - -function externalDayjs(config) { - config.externals.dayjs = { - root: 'dayjs', - commonjs2: 'dayjs', - commonjs: 'dayjs', - amd: 'dayjs', - }; -} - -function externalCssinjs(config) { - config.resolve = config.resolve || {}; - config.resolve.alias = config.resolve.alias || {}; - - config.resolve.alias['@ant-design/cssinjs'] = path.resolve(__dirname, 'alias/cssinjs'); -} - -let webpackConfig = getWebpackConfig(false); - -// Used for `size-limit` ci which only need to check min files -if (process.env.PRODUCTION_ONLY) { - // eslint-disable-next-line no-console - console.log('🍐 Build production only'); - webpackConfig = webpackConfig.filter((config) => config.mode === 'production'); -} - -if (process.env.RUN_ENV === 'PRODUCTION') { - webpackConfig.forEach((config) => { - externalDayjs(config); - externalCssinjs(config); - - // Reduce non-minified dist files size - config.optimization.usedExports = true; - // use esbuild - if (process.env.ESBUILD || process.env.CSB_REPO) { - config.optimization.minimizer[0] = new EsbuildPlugin({ - target: 'es2020', - css: true, - }); - } - - if (!process.env.CI || process.env.ANALYZER) { - config.plugins.push( - new BundleAnalyzerPlugin({ - analyzerMode: 'static', - openAnalyzer: false, - reportFilename: '../report.html', - }), - ); - } - - if (!process.env.NO_DUP_CHECK) { - config.plugins.push( - new DuplicatePackageCheckerPlugin({ - verbose: true, - emitError: true, - }), - ); - } - - config.plugins.push( - new CircularDependencyPlugin({ - // add errors to webpack instead of warnings - failOnError: true, - }), - ); - }); -} - -module.exports = [...webpackConfig];