mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
chore: fix webpack config of dist bundle (#50575)
This commit is contained in:
@@ -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,
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user