fix: antd.min error
parent
eba8f6b960
commit
678ec079bc
|
@ -22,7 +22,7 @@ const imageOptions = {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getWebpackConfig(modules, esm = false) {
|
function getWebpackConfig(modules) {
|
||||||
const pkg = require(getProjectPath('package.json'));
|
const pkg = require(getProjectPath('package.json'));
|
||||||
const babelConfig = require('./getBabelCommonConfig')(modules || false);
|
const babelConfig = require('./getBabelCommonConfig')(modules || false);
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ function getWebpackConfig(modules, esm = false) {
|
||||||
new webpack.BannerPlugin(`
|
new webpack.BannerPlugin(`
|
||||||
${pkg.name} v${pkg.version}
|
${pkg.name} v${pkg.version}
|
||||||
|
|
||||||
Copyright 2017-present, ant-design-vue.
|
Copyright 2017-present, Ant Design Vue.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
`),
|
`),
|
||||||
new WebpackBar({
|
new WebpackBar({
|
||||||
|
@ -197,6 +197,9 @@ All rights reserved.
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
config.output.library = distFileBaseName;
|
||||||
|
config.output.libraryTarget = 'umd';
|
||||||
|
config.output.globalObject = 'this';
|
||||||
config.optimization = {
|
config.optimization = {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
|
@ -207,28 +210,10 @@ All rights reserved.
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
if (esm) {
|
|
||||||
entry = ['./index.esm'];
|
|
||||||
config.experiments = {
|
|
||||||
...config.experiments,
|
|
||||||
outputModule: true,
|
|
||||||
};
|
|
||||||
config.output.chunkFormat = 'module';
|
|
||||||
config.output.library = {
|
|
||||||
type: 'module',
|
|
||||||
};
|
|
||||||
config.target = 'es2019';
|
|
||||||
} else {
|
|
||||||
config.output.libraryTarget = 'umd';
|
|
||||||
config.output.library = distFileBaseName;
|
|
||||||
}
|
|
||||||
|
|
||||||
const entryName = esm ? `${distFileBaseName}.esm` : distFileBaseName;
|
|
||||||
|
|
||||||
// Development
|
// Development
|
||||||
const uncompressedConfig = merge({}, config, {
|
const uncompressedConfig = merge({}, config, {
|
||||||
entry: {
|
entry: {
|
||||||
[entryName]: entry,
|
[distFileBaseName]: entry,
|
||||||
},
|
},
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -241,11 +226,10 @@ All rights reserved.
|
||||||
// Production
|
// Production
|
||||||
const prodConfig = merge({}, config, {
|
const prodConfig = merge({}, config, {
|
||||||
entry: {
|
entry: {
|
||||||
[`${entryName}.min`]: entry,
|
[`${distFileBaseName}.min`]: entry,
|
||||||
},
|
},
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
|
||||||
new webpack.LoaderOptionsPlugin({
|
new webpack.LoaderOptionsPlugin({
|
||||||
minimize: true,
|
minimize: true,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
"duplicate-package-checker-webpack-plugin": "^3.0.0",
|
"duplicate-package-checker-webpack-plugin": "^3.0.0",
|
||||||
"enquire-js": "^0.2.1",
|
"enquire-js": "^0.2.1",
|
||||||
"esbuild": "~0.12.29",
|
"esbuild": "~0.12.29",
|
||||||
"esbuild-loader": "^2.18.0",
|
"esbuild-loader": "^3.0.0",
|
||||||
"escape-html": "^1.0.3",
|
"escape-html": "^1.0.3",
|
||||||
"eslint": "^8.3.0",
|
"eslint": "^8.3.0",
|
||||||
"eslint-config-prettier": "^8.0.0",
|
"eslint-config-prettier": "^8.0.0",
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript></noscript>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script src="https://unpkg.com/vue@3.2.47/dist/vue.global.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
|
||||||
|
<script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script>
|
||||||
|
<script src="/Users/jinzhou/Work/ant-design-vue/dist/antd.min.js"></script>
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,6 +1,6 @@
|
||||||
// This config is for building dist files
|
// This config is for building dist files
|
||||||
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||||
const { ESBuildMinifyPlugin } = require('esbuild-loader');
|
const { EsbuildPlugin } = require('esbuild-loader');
|
||||||
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
|
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
|
||||||
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
|
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
|
||||||
|
|
||||||
|
@ -36,30 +36,7 @@ function externalDayjs(config) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function injectWarningCondition(config) {
|
|
||||||
config.module.rules.forEach(rule => {
|
|
||||||
// Remove devWarning if needed
|
|
||||||
if (rule.test.test('test.tsx')) {
|
|
||||||
rule.use = [
|
|
||||||
...rule.use,
|
|
||||||
{
|
|
||||||
loader: 'string-replace-loader',
|
|
||||||
options: {
|
|
||||||
search: 'devWarning(',
|
|
||||||
replace: "if (process.env.NODE_ENV !== 'production') devWarning(",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const webpackConfig = getWebpackConfig(false);
|
const webpackConfig = getWebpackConfig(false);
|
||||||
const webpackESMConfig = getWebpackConfig(false, true);
|
|
||||||
|
|
||||||
webpackConfig.forEach(config => {
|
|
||||||
injectWarningCondition(config);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (process.env.RUN_ENV === 'PRODUCTION') {
|
if (process.env.RUN_ENV === 'PRODUCTION') {
|
||||||
webpackConfig.forEach(config => {
|
webpackConfig.forEach(config => {
|
||||||
|
@ -69,7 +46,7 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
|
||||||
config.optimization.usedExports = true;
|
config.optimization.usedExports = true;
|
||||||
// use esbuild
|
// use esbuild
|
||||||
if (process.env.ESBUILD || process.env.CSB_REPO) {
|
if (process.env.ESBUILD || process.env.CSB_REPO) {
|
||||||
config.optimization.minimizer[0] = new ESBuildMinifyPlugin({
|
config.optimization.minimizer[0] = new EsbuildPlugin({
|
||||||
target: 'es2015',
|
target: 'es2015',
|
||||||
css: true,
|
css: true,
|
||||||
});
|
});
|
||||||
|
@ -93,4 +70,4 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = [...webpackConfig, ...webpackESMConfig];
|
module.exports = [...webpackConfig];
|
||||||
|
|
Loading…
Reference in New Issue