dpzvc-ui 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "dpzvc-ui",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Vue组件库",
5
5
  "main": "dist/dpzvc.js",
6
+ "module": "dist/dpzvc.esm.js",
6
7
  "scripts": {
7
8
  "init": "webpack --progress --config webpack.dev.config.js",
8
9
  "dev": "webpack serve --config webpack.dev.config.js --open",
@@ -1,8 +1,3 @@
1
- /**
2
- * webpack.dist.dev.config.js
3
- * 开发环境打包库文件 (Webpack 5)
4
- */
5
-
6
1
  const path = require('path');
7
2
  const webpack = require('webpack');
8
3
  const { merge } = require('webpack-merge');
@@ -10,7 +5,7 @@ const webpackBaseConfig = require('./webpack.base.config.js');
10
5
 
11
6
  process.env.NODE_ENV = 'production';
12
7
 
13
- module.exports = merge(webpackBaseConfig, {
8
+ module.exports =[merge(webpackBaseConfig, {
14
9
  mode: 'production',
15
10
 
16
11
  entry: {
@@ -46,4 +41,39 @@ module.exports = merge(webpackBaseConfig, {
46
41
  optimization: {
47
42
  minimize: false, // 开发库打包通常不压缩
48
43
  },
49
- });
44
+ }),
45
+ merge(webpackBaseConfig, {
46
+ mode: 'production',
47
+
48
+ entry: {
49
+ main: path.resolve(__dirname, './src/index.js')
50
+ },
51
+
52
+ output: {
53
+ path: path.resolve(__dirname, './dist'),
54
+ filename: 'dpzvc.esm.js', // 改名,标识 ESM
55
+ library: {
56
+ type: 'module' // ✅ 核心改动
57
+ },
58
+ clean: false
59
+ },
60
+
61
+ experiments: {
62
+ outputModule: true // ✅ 必须
63
+ },
64
+
65
+ externals: {
66
+ vue: 'vue'
67
+ },
68
+
69
+ plugins: [
70
+ new webpack.DefinePlugin({
71
+ 'process.env.NODE_ENV': JSON.stringify('production')
72
+ })
73
+ ],
74
+
75
+ optimization: {
76
+ concatenateModules: false,
77
+ minimize: false
78
+ }
79
+ })];
@@ -1,8 +1,3 @@
1
- /**
2
- * webpack.dist.prod.config.js
3
- * 生产环境打包库文件 (Webpack 5)
4
- */
5
-
6
1
  const path = require('path');
7
2
  const webpack = require('webpack');
8
3
  const TerserPlugin = require('terser-webpack-plugin');
@@ -11,7 +6,43 @@ const webpackBaseConfig = require('./webpack.base.config.js');
11
6
 
12
7
  process.env.NODE_ENV = 'production';
13
8
 
14
- module.exports = merge(webpackBaseConfig, {
9
+ module.exports =[
10
+ // -------- UMD 输出 --------
11
+ merge(webpackBaseConfig, {
12
+ mode: 'production',
13
+ entry: {
14
+ main: path.resolve(__dirname, './src/index.js')
15
+ },
16
+ output: {
17
+ path: path.resolve(__dirname, './dist'),
18
+ filename: 'dpzvc.min.js',
19
+ library: 'dpzvc',
20
+ libraryTarget: 'umd',
21
+ umdNamedDefine: true,
22
+ clean: false
23
+ },
24
+ externals: {
25
+ vue: 'Vue'
26
+ },
27
+ optimization: {
28
+ minimize: true,
29
+ minimizer: [
30
+ new TerserPlugin({
31
+ terserOptions: {
32
+ compress: { drop_console: true, drop_debugger: true },
33
+ output: { comments: false }
34
+ },
35
+ extractComments: false
36
+ })
37
+ ]
38
+ },
39
+ plugins: [
40
+ new webpack.DefinePlugin({
41
+ 'process.env.NODE_ENV': JSON.stringify('production')
42
+ })
43
+ ]
44
+ }),
45
+ merge(webpackBaseConfig, {
15
46
  mode: 'production',
16
47
 
17
48
  entry: {
@@ -20,34 +51,33 @@ module.exports = merge(webpackBaseConfig, {
20
51
 
21
52
  output: {
22
53
  path: path.resolve(__dirname, './dist'),
23
- publicPath: '/dist/',
24
- filename: 'dpzvc.min.js',
25
- library: 'dpzvc',
26
- libraryTarget: 'umd',
27
- umdNamedDefine: true,
28
- clean: false // webpack5 新增,每次构建清理旧文件
54
+ filename: 'dpzvc.esm.min.js', // ESM 文件
55
+ library: {
56
+ type: 'module' // 核心 ESM 输出
57
+ },
58
+ clean: false
59
+ },
60
+
61
+ experiments: {
62
+ outputModule: true
29
63
  },
30
64
 
31
65
  externals: {
32
- vue: {
33
- root: 'Vue',
34
- commonjs: 'vue',
35
- commonjs2: 'vue',
36
- amd: 'vue'
37
- }
66
+ vue: 'vue'
38
67
  },
39
68
 
40
69
  optimization: {
70
+ concatenateModules: false,
41
71
  minimize: true,
42
72
  minimizer: [
43
73
  new TerserPlugin({
44
74
  terserOptions: {
45
75
  compress: { drop_console: true, drop_debugger: true },
46
- output: { comments: false },
76
+ output: { comments: false }
47
77
  },
48
- extractComments: false, // 防止生成 LICENSE.txt
78
+ extractComments: false
49
79
  })
50
- ],
80
+ ]
51
81
  },
52
82
 
53
83
  plugins: [
@@ -55,4 +85,4 @@ module.exports = merge(webpackBaseConfig, {
55
85
  'process.env.NODE_ENV': JSON.stringify('production')
56
86
  })
57
87
  ]
58
- });
88
+ })];