Skip to content

Commit 4b4e1fb

Browse files
authored
fix: 移除不必要的 CleanWebpackPlugin 依赖,更新 prebuild 脚本为 rimraf (#35)
1 parent 8aa2f34 commit 4b4e1fb

3 files changed

Lines changed: 121 additions & 64 deletions

File tree

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,67 @@
1-
const path = require("path");
2-
const webpack = require("webpack");
3-
const { VueLoaderPlugin } = require("vue-loader");
4-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
5-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
6-
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
7-
const EsbuildPlugin = require("./plugins/esbuild-plugin");
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const { VueLoaderPlugin } = require('vue-loader');
4+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
6+
const EsbuildPlugin = require('./plugins/esbuild-plugin');
87

9-
const root = path.resolve(__dirname, "..");
10-
const pkg = require(path.resolve(root, "./package.json"));
8+
const root = path.resolve(__dirname, '..');
9+
const pkg = require(path.resolve(root, './package.json'));
1110

12-
const publicPath = "/";
11+
const publicPath = '/';
1312

14-
const library = "cloudAdminDesigner";
13+
const library = 'cloudAdminDesigner';
1514

16-
const extensions = [".vue", ".js", ".ts", ".json", ".css"];
15+
const extensions = ['.vue', '.js', '.ts', '.json', '.css'];
1716

1817
const baseConfig = (type) => {
1918
return {
20-
mode: "production",
21-
devtool: "source-map",
22-
entry: [path.resolve(root, `./src/assets/css/index.${type}.css`), path.resolve(root, "./src/init.js")],
19+
mode: 'production',
20+
devtool: 'source-map',
21+
entry: [path.resolve(root, `./src/assets/css/index.${type}.css`), path.resolve(root, './src/init.js')],
2322
output: {
2423
publicPath,
2524
path: path.resolve(root, `dist/${type}`),
2625
filename: `${library}.umd.min.js`,
2726
library: {
2827
name: library,
29-
type: "umd",
28+
type: 'umd',
3029
umdNamedDefine: true,
31-
export: "default",
30+
export: 'default',
3231
},
3332
},
3433
resolve: {
3534
alias: {
36-
"@": path.resolve(root, "src"),
35+
'@': path.resolve(root, 'src'),
3736
},
3837
extensions: [...extensions, ...extensions.map((ext) => `.${type}${ext}`)],
3938
},
4039
externals: {
4140
vue: {
42-
root: "Vue",
43-
commonjs: "vue",
44-
commonjs2: "vue",
45-
amd: "vue",
41+
root: 'Vue',
42+
commonjs: 'vue',
43+
commonjs2: 'vue',
44+
amd: 'vue',
4645
},
4746
},
4847
module: {
4948
rules: [
5049
{
5150
test: /\.vue$/,
52-
loader: "vue-loader",
51+
loader: 'vue-loader',
5352
},
5453
{
5554
test: /\.js$/,
56-
loader: "babel-loader",
55+
loader: 'babel-loader',
5756
},
5857
{
5958
test: /\.ts$/,
6059
use: [
6160
{
62-
loader: "babel-loader",
61+
loader: 'babel-loader',
6362
},
6463
{
65-
loader: "ts-loader",
64+
loader: 'ts-loader',
6665
},
6766
],
6867
},
@@ -71,13 +70,13 @@ const baseConfig = (type) => {
7170
use: [
7271
MiniCssExtractPlugin.loader,
7372
{
74-
loader: "css-loader",
73+
loader: 'css-loader',
7574
},
7675
{
77-
loader: "postcss-loader",
76+
loader: 'postcss-loader',
7877
options: {
7978
postcssOptions: {
80-
plugins: ["autoprefixer"],
79+
plugins: ['autoprefixer'],
8180
},
8281
},
8382
},
@@ -88,31 +87,30 @@ const baseConfig = (type) => {
8887
optimization: {
8988
minimizer: [
9089
new EsbuildPlugin({
91-
target: "es2015",
90+
target: 'es2015',
9291
css: true,
9392
}),
9493
],
9594
},
9695
plugins: [
9796
new webpack.ProvidePlugin({
98-
process: require.resolve("process/browser"),
97+
process: require.resolve('process/browser'),
9998
}),
10099
new VueLoaderPlugin(),
101100
new MiniCssExtractPlugin({
102101
filename: `${library}.css`,
103102
}),
104103
new webpack.ProgressPlugin(),
105-
new CleanWebpackPlugin(),
106104
// new BundleAnalyzerPlugin({
107105
// analyzerMode: "static",
108106
// openAnalyzer: false,
109107
// reportFilename: `report-${type}.html`,
110108
// }),
111109
],
112-
stats: "minimal",
110+
stats: 'minimal',
113111
};
114112
};
115113

116-
module.exports = [baseConfig("pc"), baseConfig("mobile")];
114+
module.exports = [baseConfig('pc'), baseConfig('mobile')];
117115

118116
exports.baseConfig = baseConfig;

packages/vue2/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"dev": "webpack-dev-server --config build/webpack.dev.config.js",
77
"build": "webpack --config build/webpack.config.js",
8-
"prebuild": "rm -rf dist",
8+
"prebuild": "rimraf ./dist",
99
"postbuild": "npm run zip",
1010
"zip": "node ./scripts/zip.js",
1111
"deploy": "node ./scripts/deploy.js"
@@ -23,11 +23,11 @@
2323
"@lcap/basic-template": "workspace:*",
2424
"@vusion/utils": "^0.4.10",
2525
"babel-polyfill": "^6.26.0",
26+
"date-fns": "^2.6.0",
27+
"lodash": "^4.17.15",
2628
"process": "^0.11.10",
2729
"vue": "2.6.12",
2830
"vue-i18n": "^8.28.2",
29-
"date-fns": "^2.6.0",
30-
"lodash": "^4.17.15",
3131
"vue-router": "^3.1.2"
3232
},
3333
"devDependencies": {
@@ -43,6 +43,7 @@
4343
"minimist": "^1.2.8",
4444
"postcss": "^8.4.38",
4545
"postcss-loader": "^8.1.1",
46+
"rimraf": "^6.0.1",
4647
"ts-loader": "^9.5.1",
4748
"typescript": "^5.3.3",
4849
"vue-loader": "^15.11.1",

0 commit comments

Comments
 (0)