This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpack.common.js
100 lines (98 loc) · 2 KB
/
webpack.common.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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: {
popup: './src/js/Popup.js',
custom: './src/js/SetupCustom.js',
background: './src/js/Background.js',
director: './src/js/Director.js'
},
output: {
filename: '[name].js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /\.(png|jpg|gif|svg|woff2)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader'
}
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
plugins: [
new CleanWebpackPlugin(),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
filename: 'popup.html',
template: 'src/template.html',
chunks: ['popup', 'commons']
}),
new HtmlWebpackPlugin({
filename: 'custom.html',
template: 'src/template.html',
chunks: ['custom', 'commons']
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/template.html',
chunks: ['director', 'commons']
}),
new CopyWebpackPlugin([
{
from: 'src/manifest.json',
transform: content =>
Buffer.from(
JSON.stringify({
description: process.env.npm_package_description,
version: process.env.npm_package_version,
...JSON.parse(content.toString())
})
)
},
{ from: 'src/static/', to: 'static/' }
])
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks(chunk) {
return chunk.name !== 'background';
},
minChunks: 1
}
}
},
minimize: true,
minimizer: [new UglifyJsPlugin()]
}
};