chore: fix webpack config of dist bundle (#50575)

This commit is contained in:
afc163
2024-08-27 09:55:59 +08:00
committed by GitHub
parent 4e446e1c06
commit cab753c52c
4 changed files with 9 additions and 25 deletions

View File

@@ -27,5 +27,4 @@ jobs:
env:
NODE_OPTIONS: "--max_old_space_size=4096"
PRODUCTION_ONLY: 1
NO_DUP_CHECK: 1
CI_JOB_NUMBER: 1

View File

@@ -9,7 +9,8 @@
"_site/**/*",
"node_modules",
"server",
"scripts/previewEditor/**/*"
"scripts/previewEditor/**/*",
"package.json"
]
},
"formatter": {

View File

@@ -53,8 +53,6 @@
"deploy:china-mirror": "git checkout gh-pages && git pull origin gh-pages && git push git@gitee.com:ant-design/ant-design.git gh-pages -f",
"predist": "npm run version && npm run token:statistic && npm run token:meta",
"dist": "antd-tools run dist",
"dist:esbuild": "ESBUILD=true npm run dist",
"dist:esbuild-no-dup-check": "ESBUILD=true NO_DUP_CHECK=true npm run dist",
"format": "biome format --write .",
"install-react-16": "npm i --no-save --legacy-peer-deps react@16 react-dom@16 @testing-library/react@12",
"install-react-17": "npm i --no-save --legacy-peer-deps react@17 react-dom@17 @testing-library/react@12",
@@ -240,7 +238,6 @@
"dotenv": "^16.4.5",
"dumi": "~2.4.5",
"dumi-plugin-color-chunk": "^1.1.1",
"esbuild-loader": "^4.2.1",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.1.0",

View File

@@ -3,7 +3,6 @@
const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { codecovWebpackPlugin } = require('@codecov/webpack-plugin');
const { EsbuildPlugin } = require('esbuild-loader');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const DuplicatePackageCheckerPlugin = require('@madccc/duplicate-package-checker-webpack-plugin');
const path = require('path');
@@ -40,32 +39,16 @@ if (process.env.PRODUCTION_ONLY) {
// eslint-disable-next-line no-console
console.log('🍐 Build production only');
webpackConfig = webpackConfig.filter((config) => config.mode === 'production');
webpackConfig.forEach((config) => {
config.plugins.push(
codecovWebpackPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'antd',
uploadToken: process.env.CODECOV_TOKEN,
}),
);
});
}
// RUN_ENV: https://github.com/ant-design/antd-tools/blob/14ee166fc1f4ab5e87da45ee3b0643a8325f1bc3/lib/gulpfile.js#L48
if (process.env.RUN_ENV === 'PRODUCTION') {
webpackConfig.forEach((config) => {
addLocales(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: 'es2015',
css: true,
});
}
if (!process.env.CI || process.env.ANALYZER) {
config.plugins.push(
@@ -77,7 +60,11 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
);
}
if (!process.env.NO_DUP_CHECK) {
if (config.mode !== 'production') {
return;
}
if (!process.env.PRODUCTION_ONLY) {
config.plugins.push(
new DuplicatePackageCheckerPlugin({
verbose: true,
@@ -89,7 +76,7 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
config.plugins.push(
codecovWebpackPlugin({
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
bundleName: 'antd',
bundleName: 'antd.min',
uploadToken: process.env.CODECOV_TOKEN,
}),
);