Skip to content

Commit 678ec07

Browse files
committed
fix: antd.min error
1 parent eba8f6b commit 678ec07

File tree

4 files changed

+34
-50
lines changed

4 files changed

+34
-50
lines changed

antd-tools/getWebpackConfig.js

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const imageOptions = {
2222
limit: 10000,
2323
};
2424

25-
function getWebpackConfig(modules, esm = false) {
25+
function getWebpackConfig(modules) {
2626
const pkg = require(getProjectPath('package.json'));
2727
const babelConfig = require('./getBabelCommonConfig')(modules || false);
2828

@@ -170,7 +170,7 @@ function getWebpackConfig(modules, esm = false) {
170170
new webpack.BannerPlugin(`
171171
${pkg.name} v${pkg.version}
172172
173-
Copyright 2017-present, ant-design-vue.
173+
Copyright 2017-present, Ant Design Vue.
174174
All rights reserved.
175175
`),
176176
new WebpackBar({
@@ -197,6 +197,9 @@ All rights reserved.
197197
},
198198
},
199199
];
200+
config.output.library = distFileBaseName;
201+
config.output.libraryTarget = 'umd';
202+
config.output.globalObject = 'this';
200203
config.optimization = {
201204
minimizer: [
202205
new TerserPlugin({
@@ -207,28 +210,10 @@ All rights reserved.
207210
}),
208211
],
209212
};
210-
if (esm) {
211-
entry = ['./index.esm'];
212-
config.experiments = {
213-
...config.experiments,
214-
outputModule: true,
215-
};
216-
config.output.chunkFormat = 'module';
217-
config.output.library = {
218-
type: 'module',
219-
};
220-
config.target = 'es2019';
221-
} else {
222-
config.output.libraryTarget = 'umd';
223-
config.output.library = distFileBaseName;
224-
}
225-
226-
const entryName = esm ? `${distFileBaseName}.esm` : distFileBaseName;
227-
228213
// Development
229214
const uncompressedConfig = merge({}, config, {
230215
entry: {
231-
[entryName]: entry,
216+
[distFileBaseName]: entry,
232217
},
233218
mode: 'development',
234219
plugins: [
@@ -241,11 +226,10 @@ All rights reserved.
241226
// Production
242227
const prodConfig = merge({}, config, {
243228
entry: {
244-
[`${entryName}.min`]: entry,
229+
[`${distFileBaseName}.min`]: entry,
245230
},
246231
mode: 'production',
247232
plugins: [
248-
new webpack.optimize.ModuleConcatenationPlugin(),
249233
new webpack.LoaderOptionsPlugin({
250234
minimize: true,
251235
}),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
"duplicate-package-checker-webpack-plugin": "^3.0.0",
166166
"enquire-js": "^0.2.1",
167167
"esbuild": "~0.12.29",
168-
"esbuild-loader": "^2.18.0",
168+
"esbuild-loader": "^3.0.0",
169169
"escape-html": "^1.0.3",
170170
"eslint": "^8.3.0",
171171
"eslint-config-prettier": "^8.0.0",

test.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
7+
</head>
8+
<body>
9+
<noscript></noscript>
10+
<div id="app"></div>
11+
<script src="https://unpkg.com/[email protected]/dist/vue.global.js"></script>
12+
<script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
13+
<script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
14+
<script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
15+
<script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
16+
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
17+
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
18+
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
19+
<script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script>
20+
<script src="/Users/jinzhou/Work/ant-design-vue/dist/antd.min.js"></script>
21+
<!-- built files will be auto injected -->
22+
</body>
23+
</html>

webpack.build.conf.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This config is for building dist files
22
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
3-
const { ESBuildMinifyPlugin } = require('esbuild-loader');
3+
const { EsbuildPlugin } = require('esbuild-loader');
44
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
55
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
66

@@ -36,30 +36,7 @@ function externalDayjs(config) {
3636
});
3737
}
3838

39-
function injectWarningCondition(config) {
40-
config.module.rules.forEach(rule => {
41-
// Remove devWarning if needed
42-
if (rule.test.test('test.tsx')) {
43-
rule.use = [
44-
...rule.use,
45-
{
46-
loader: 'string-replace-loader',
47-
options: {
48-
search: 'devWarning(',
49-
replace: "if (process.env.NODE_ENV !== 'production') devWarning(",
50-
},
51-
},
52-
];
53-
}
54-
});
55-
}
56-
5739
const webpackConfig = getWebpackConfig(false);
58-
const webpackESMConfig = getWebpackConfig(false, true);
59-
60-
webpackConfig.forEach(config => {
61-
injectWarningCondition(config);
62-
});
6340

6441
if (process.env.RUN_ENV === 'PRODUCTION') {
6542
webpackConfig.forEach(config => {
@@ -69,7 +46,7 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
6946
config.optimization.usedExports = true;
7047
// use esbuild
7148
if (process.env.ESBUILD || process.env.CSB_REPO) {
72-
config.optimization.minimizer[0] = new ESBuildMinifyPlugin({
49+
config.optimization.minimizer[0] = new EsbuildPlugin({
7350
target: 'es2015',
7451
css: true,
7552
});
@@ -93,4 +70,4 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
9370
});
9471
}
9572

96-
module.exports = [...webpackConfig, ...webpackESMConfig];
73+
module.exports = [...webpackConfig];

0 commit comments

Comments
 (0)