chore: update webpack
parent
553554d72f
commit
02b934c33d
|
@ -73,3 +73,5 @@ site/dev.js
|
|||
|
||||
# IDE 语法提示临时文件
|
||||
vetur/
|
||||
|
||||
report.html
|
||||
|
|
|
@ -8,16 +8,17 @@ import { withInstall } from '../_util/type';
|
|||
import type { ValidateMessages } from '../form/interface';
|
||||
import type { TransferLocale } from '../transfer';
|
||||
import type { PickerLocale as DatePickerLocale } from '../date-picker/generatePicker';
|
||||
import { PaginationLocale } from '../pagination/Pagination';
|
||||
|
||||
interface TransferLocaleForEmpty {
|
||||
description: string;
|
||||
}
|
||||
export interface Locale {
|
||||
locale: string;
|
||||
Pagination?: Object;
|
||||
Table?: Object;
|
||||
Popconfirm?: Object;
|
||||
Upload?: Object;
|
||||
Pagination?: PaginationLocale;
|
||||
Table?: Record<string, any>;
|
||||
Popconfirm?: Record<string, any>;
|
||||
Upload?: Record<string, any>;
|
||||
Form?: {
|
||||
optional?: string;
|
||||
defaultValidateMessages: ValidateMessages;
|
||||
|
@ -72,9 +73,9 @@ const LocaleProvider = defineComponent({
|
|||
() => props.locale,
|
||||
val => {
|
||||
state.antLocale = {
|
||||
...val,
|
||||
...props.locale,
|
||||
exist: true,
|
||||
};
|
||||
} as any;
|
||||
changeConfirmLocale(val && val.Modal);
|
||||
},
|
||||
{ immediate: true },
|
||||
|
|
|
@ -51,6 +51,7 @@ export const paginationConfig = () => ({
|
|||
export type PaginationProps = Partial<ExtractPropTypes<ReturnType<typeof paginationProps>>>;
|
||||
export type PaginationConfig = Partial<ExtractPropTypes<ReturnType<typeof paginationConfig>>>;
|
||||
|
||||
export type PaginationLocale = any;
|
||||
export default defineComponent({
|
||||
name: 'APagination',
|
||||
inheritAttrs: false,
|
||||
|
|
|
@ -212,7 +212,7 @@ export default defineComponent({
|
|||
if (!!filterOption === false) {
|
||||
return true;
|
||||
}
|
||||
return filterOption(targetMeasureText, option);
|
||||
return (filterOption as Function)(targetMeasureText, option);
|
||||
});
|
||||
return list;
|
||||
};
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
"vue-style-loader": "^4.1.2",
|
||||
"vuex": "^4.0.0-beta.2",
|
||||
"webpack": "^5.0.0",
|
||||
"webpack-bundle-analyzer": "^4.0.0",
|
||||
"webpack-bundle-analyzer": "^4.4.2",
|
||||
"webpack-cli": "^4.6.0",
|
||||
"webpack-dev-server": "^3.1.14",
|
||||
"webpack-merge": "^5.0.0",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// This config is for building dist files
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
|
||||
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
|
||||
const darkVars = require('./scripts/dark-vars');
|
||||
|
@ -21,41 +22,55 @@ function externalDayjs(config) {
|
|||
};
|
||||
}
|
||||
|
||||
function processWebpackThemeConfig(themeConfig, theme, vars) {
|
||||
themeConfig.forEach(config => {
|
||||
externalDayjs(config);
|
||||
|
||||
// rename default entry to ${theme} entry
|
||||
Object.keys(config.entry).forEach(entryName => {
|
||||
config.entry[entryName.replace('antd', `antd.${theme}`)] = config.entry[entryName];
|
||||
delete config.entry[entryName];
|
||||
});
|
||||
|
||||
// apply ${theme} less variables
|
||||
config.module.rules.forEach(rule => {
|
||||
// filter less rule
|
||||
if (rule.test instanceof RegExp && rule.test.test('.less')) {
|
||||
const lessRule = rule.use[rule.use.length - 1];
|
||||
if (lessRule.options.lessOptions) {
|
||||
lessRule.options.lessOptions.modifyVars = vars;
|
||||
} else {
|
||||
lessRule.options.modifyVars = vars;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const themeReg = new RegExp(`${theme}(.min)?\\.js(\\.map)?$`);
|
||||
// ignore emit ${theme} entry js & js.map file
|
||||
config.plugins.push(new IgnoreEmitPlugin(themeReg));
|
||||
});
|
||||
}
|
||||
|
||||
const webpackConfig = getWebpackConfig(false);
|
||||
const webpackDarkConfig = getWebpackConfig(false);
|
||||
|
||||
if (process.env.RUN_ENV === 'PRODUCTION') {
|
||||
webpackConfig.forEach(config => {
|
||||
externalDayjs(config);
|
||||
addLocales(config);
|
||||
// Reduce non-minified dist files size
|
||||
config.optimization.usedExports = true;
|
||||
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false,
|
||||
reportFilename: '../report.html',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
processWebpackThemeConfig(webpackDarkConfig, 'dark', darkVars);
|
||||
}
|
||||
|
||||
const webpackDarkConfig = getWebpackConfig(false);
|
||||
|
||||
webpackDarkConfig.forEach(config => {
|
||||
externalDayjs(config);
|
||||
|
||||
// rename default entry to ${theme} entry
|
||||
Object.keys(config.entry).forEach(entryName => {
|
||||
config.entry[entryName.replace('antd', `antd.dark`)] = config.entry[entryName];
|
||||
delete config.entry[entryName];
|
||||
});
|
||||
|
||||
// apply ${theme} less variables
|
||||
config.module.rules.forEach(rule => {
|
||||
// filter less rule
|
||||
if (rule.test instanceof RegExp && rule.test.test('.less')) {
|
||||
const lessRule = rule.use[rule.use.length - 1];
|
||||
if (lessRule.options.lessOptions) {
|
||||
lessRule.options.lessOptions.modifyVars = darkVars;
|
||||
} else {
|
||||
lessRule.options.modifyVars = darkVars;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const themeReg = new RegExp(`dark(.min)?\\.js(\\.map)?`);
|
||||
// ignore emit ${theme} entry js & js.map file
|
||||
config.plugins.push(new IgnoreEmitPlugin(themeReg));
|
||||
});
|
||||
|
||||
module.exports = webpackConfig.concat(webpackDarkConfig);
|
||||
|
|
Loading…
Reference in New Issue