mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-23 18:50:06 +08:00
chore: umd version will try to reuse global @ant-design/cssinjs
first (#46009)
* chore: alias of it * chore: comment
This commit is contained in:
parent
e5a69664c3
commit
3233ac498f
19
alias/cssinjs.js
Normal file
19
alias/cssinjs.js
Normal file
@ -0,0 +1,19 @@
|
||||
/* eslint-disable global-require, import/no-unresolved */
|
||||
|
||||
// This is a alias proxy, which will use global `@ant-design/cssinjs` first.
|
||||
// Use local if global not found.
|
||||
let cssinjs;
|
||||
|
||||
if (typeof window !== 'undefined' && window.antdCssinjs) {
|
||||
// Use window UMD version
|
||||
cssinjs = window.antdCssinjs;
|
||||
} else if (typeof global !== 'undefined' && global.antdCssinjs) {
|
||||
// Use global UMD version
|
||||
cssinjs = global.antdCssinjs;
|
||||
} else {
|
||||
// Use local version.
|
||||
// Use relative path since webpack will also replace module here.
|
||||
cssinjs = require('../node_modules/@ant-design/cssinjs');
|
||||
}
|
||||
|
||||
module.exports = cssinjs;
|
@ -5,6 +5,7 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const { EsbuildPlugin } = require('esbuild-loader');
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
|
||||
const path = require('path');
|
||||
|
||||
function addLocales(webpackConfig) {
|
||||
let packageName = 'antd-with-locales';
|
||||
@ -24,6 +25,13 @@ function externalDayjs(config) {
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
@ -37,6 +45,8 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user