Skip to content

Commit b51f25f

Browse files
committed
chore: update webpack config
1 parent dcb34b0 commit b51f25f

File tree

3 files changed

+47
-53
lines changed

3 files changed

+47
-53
lines changed

antd-tools/getWebpackConfig.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ const path = require('path');
44
const webpack = require('webpack');
55
const WebpackBar = require('webpackbar');
66
const { merge } = require('webpack-merge');
7+
const TerserPlugin = require('terser-webpack-plugin');
78
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
8-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
9+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
910
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
1011
const CleanUpStatsPlugin = require('./utils/CleanUpStatsPlugin');
1112
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
@@ -207,6 +208,9 @@ All rights reserved.
207208
}),
208209
new CleanUpStatsPlugin(),
209210
],
211+
performance: {
212+
hints: false,
213+
},
210214
};
211215

212216
if (process.env.RUN_ENV === 'PRODUCTION') {
@@ -223,17 +227,12 @@ All rights reserved.
223227
config.output.libraryTarget = 'umd';
224228
config.optimization = {
225229
minimizer: [
226-
// eslint-disable-next-line no-unused-vars
227-
compiler => {
228-
return () => {
229-
return {
230-
parallel: true,
231-
terserOptions: {
232-
warnings: false,
233-
},
234-
};
235-
};
236-
},
230+
new TerserPlugin({
231+
parallel: true,
232+
terserOptions: {
233+
warnings: false,
234+
},
235+
}),
237236
],
238237
};
239238

@@ -266,7 +265,8 @@ All rights reserved.
266265
}),
267266
],
268267
optimization: {
269-
minimizer: [new OptimizeCSSAssetsPlugin({})],
268+
minimize: true,
269+
minimizer: [new CssMinimizerPlugin({})],
270270
},
271271
});
272272

antd-tools/gulpfile.js

+31-38
Original file line numberDiff line numberDiff line change
@@ -308,61 +308,54 @@ function publish(tagString, done) {
308308
}
309309

310310
function pub(done) {
311-
dist(code => {
312-
if (code) {
313-
done(code);
314-
return;
315-
}
316-
const notOk = !packageJson.version.match(/^\d+\.\d+\.\d+$/);
317-
let tagString;
318-
if (argv['npm-tag']) {
319-
tagString = argv['npm-tag'];
320-
}
321-
if (!tagString && notOk) {
322-
tagString = 'next';
323-
}
324-
if (packageJson.scripts['pre-publish']) {
325-
runCmd('npm', ['run', 'pre-publish'], code2 => {
326-
if (code2) {
327-
done(code2);
328-
return;
329-
}
330-
publish(tagString, done);
331-
});
332-
} else {
311+
const notOk = !packageJson.version.match(/^\d+\.\d+\.\d+$/);
312+
let tagString;
313+
if (argv['npm-tag']) {
314+
tagString = argv['npm-tag'];
315+
}
316+
if (!tagString && notOk) {
317+
tagString = 'next';
318+
}
319+
if (packageJson.scripts['pre-publish']) {
320+
runCmd('npm', ['run', 'pre-publish'], code2 => {
321+
if (code2) {
322+
done(code2);
323+
return;
324+
}
333325
publish(tagString, done);
334-
}
335-
});
326+
});
327+
} else {
328+
publish(tagString, done);
329+
}
336330
}
337331

338-
gulp.task(
339-
'compile-with-es',
340-
gulp.series(done => {
341-
compile(false).on('finish', function() {
342-
done();
343-
});
344-
}),
345-
);
332+
gulp.task('compile-with-es', done => {
333+
console.log('[Parallel] Compile to es...');
334+
compile(false).on('finish', done);
335+
});
336+
337+
gulp.task('compile-with-lib', done => {
338+
console.log('[Parallel] Compile to js...');
339+
compile().on('finish', done);
340+
});
346341

347342
gulp.task(
348343
'compile',
349-
gulp.series('compile-with-es', done => {
350-
compile().on('finish', function() {
351-
done();
352-
});
344+
gulp.series(gulp.parallel('compile-with-es', 'compile-with-lib'), done => {
345+
done();
353346
}),
354347
);
355348

356349
gulp.task(
357350
'dist',
358-
gulp.series('compile', done => {
351+
gulp.series(done => {
359352
dist(done);
360353
}),
361354
);
362355

363356
gulp.task(
364357
'pub',
365-
gulp.series('check-git', 'compile', done => {
358+
gulp.series('check-git', 'compile', 'dist', done => {
366359
// if (!process.env.GITHUB_TOKEN) {
367360
// console.log('no GitHub token found, skip');
368361
// } else {

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"test:dev": "cross-env NODE_ENV=test jest --config .jest.js",
3434
"compile": "node antd-tools/cli/run.js compile",
3535
"generator-webtypes": "tsc -p antd-tools/generator-types/tsconfig.json && node antd-tools/generator-types/index.js",
36-
"pub": "node antd-tools/cli/run.js pub",
36+
"pub": "node --max_old_space_size=8192 antd-tools/cli/run.js pub",
3737
"pub-with-ci": "node antd-tools/cli/run.js pub-with-ci",
3838
"prepublish": "node antd-tools/cli/run.js guard",
3939
"pre-publish": "node ./scripts/prepub && npm run generator-webtypes",
@@ -112,6 +112,7 @@
112112
"compare-versions": "^3.3.0",
113113
"cross-env": "^7.0.0",
114114
"css-loader": "^5.0.0",
115+
"css-minimizer-webpack-plugin": "^2.0.0",
115116
"deep-assign": "^3.0.0",
116117
"docsearch.js": "^2.6.3",
117118
"enquire-js": "^0.2.1",
@@ -151,7 +152,6 @@
151152
"mkdirp": "^0.5.1",
152153
"mockdate": "^2.0.2",
153154
"nprogress": "^0.2.0",
154-
"optimize-css-assets-webpack-plugin": "^5.0.1",
155155
"postcss": "^8.2.12",
156156
"postcss-loader": "^5.0.0",
157157
"prettier": "^1.18.2",
@@ -171,6 +171,7 @@
171171
"stylelint-config-standard": "^22.0.0",
172172
"stylelint-declaration-block-no-ignored-properties": "^2.1.0",
173173
"stylelint-order": "^4.0.0",
174+
"terser-webpack-plugin": "^5.1.1",
174175
"through2": "^3.0.0",
175176
"ts-jest": "^26.4.1",
176177
"ts-loader": "^9.1.0",

0 commit comments

Comments
 (0)