-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
87 lines (86 loc) · 2.02 KB
/
webpack.config.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
// doc: https://github.com/NightCatSama/vue-slider-component/blob/master/webpack.config.js
// doc: https://juejin.im/post/586f8252128fe1006b1ebf9e
// webpack4: https://github.com/dwqs/blog/issues/60
var path = require('path')
// var webpack = require('webpack')
var VueLoaderPlugin = require('vue-loader/lib/plugin')
const TerserPlugin = require('terser-webpack-plugin')
module.exports = {
mode: 'production',
devtool: 'cheap-module-source-map',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'index.js',
library: 'vue-markdown-it-toc',
libraryTarget: 'umd',
umdNamedDefine: true
},
resolve: {
extensions: ['.js', '.vue']
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
// 开启缓存
cache: true,
// 开启多线程压缩
parallel: true,
terserOptions: {
compress: {
// 只删除console.log, 注意: ie9不支持console相关api
pure_funcs: [ 'console.log' ]
}
}
})
]
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
// include: __dirname,
exclude: /node_modules/
},
{
test: /\.vue$/,
use: 'vue-loader',
// include: __dirname,
exclude: /node_modules/
// options: {
// postcss: {
// config: {
// path: path.resolve(__dirname, './postcss.config.js')
// }
// }
// }
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader'
// ,
// options: {
// // 你也可以从一个文件读取,例如 `variables.scss`
// data: `$color: red;`
// }
}
]
},
{
test: /\.css$/,
use: [
'css-loader'
]
}
]
},
plugins: [
new VueLoaderPlugin()
]
}