-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.webpack.component.js
116 lines (115 loc) · 2.57 KB
/
build.webpack.component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* @Author: shiliangL
* @Date: 2022-05-07 09:03:15
* @LastEditTime: 2022-05-13 11:53:28
* @LastEditors: Do not edit
* @Description:
*/
const path = require('path')
const { VueLoaderPlugin } = require('vue-loader')
const TerserPlugin = require('terser-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const { getComponentEntries } = require('./build/utils')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
const CssMiniMizerPlugin = require('css-minimizer-webpack-plugin')
module.exports = {
mode: 'production',
entry: {
...getComponentEntries('src/packages')
},
output: {
path: path.join(__dirname, '/lib'),
filename: '[name]/index.js',
libraryExport: 'default',
library: 'element-kit',
libraryTarget: 'umd',
umdNamedDefine: true
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': path.resolve(__dirname, './src')
},
modules: ['node_modules']
},
performance: {
hints: false
},
stats: {
children: false
},
externals: {
'vue': {
amd: 'vue',
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue'
},
'element-ui': 'ELEMENT'
},
optimization: {
minimize: true,
minimizer: [
new CssMiniMizerPlugin({
parallel: true
}),
new TerserPlugin({
parallel: true,
extractComments: false,
terserOptions: {
format: {
comments: false
},
compress: true,
mangle: true,
toplevel: false,
keep_classnames: false
}
})
]
},
module: {
rules: [
{
test: /\.vue$/,
exclude: /node_modules/,
use: ['vue-loader']
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
},
{
test: /\.s[ac]ss$/i,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
'postcss-loader'
]
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
}
]
},
plugins: [
new UglifyJsPlugin(),
new VueLoaderPlugin(),
new ProgressBarPlugin(),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: 'style/[name].css'
})
]
}