-
Notifications
You must be signed in to change notification settings - Fork 135
/
webpack.config.js
77 lines (77 loc) · 1.9 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
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const PACKAGE = require('./package.json');
const ZipPlugin = require('zip-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const path = require('path');
const glob = require("glob");
module.exports = env=>({
mode: 'production',
entry: {
service: ['./Extension/background.js'],
content: [
'./Extension/contentScript.js',
"./Extension/content.scss",
"./Extension/icon_48.png",
"./Extension/icon_96.png",
...glob.sync(__dirname + "/Extension/*.svg")
],
ui: [
'./Extension/options.js',
'./Extension/popup.js',
'./Extension/ui.scss',
...glob.sync(__dirname + "/Extension/*.html")
],
editor: [
...glob.sync(__dirname + "/Extension/editor/js/*.js"),
'./Extension/editor/scss/main.scss',
...glob.sync(__dirname + "/Extension/editor/*.html")
]
},
output: {
publicPath: "",
filename: '[name].js',
path: path.resolve(__dirname, 'build')
},
module: {
parser: {
javascript: {
exportsPresence: "error",
importExportsPresence: "error"
}
},
rules: [
{
test: /\.(png|json|svg|html)/,
type: 'asset/resource',
generator: {
filename: '[name][ext]'
}
},
{
test: /\.(sc|sa)ss$/i,
type: 'asset/resource',
use: [
"sass-loader"
],
generator: {
filename: '[name].css'
}
},
]
},
optimization: {
minimize: true,
minimizer: [
'...',
new HtmlMinimizerPlugin(),
],
},
plugins: [
new CopyPlugin({patterns: [{from: "Extension/manifest."+env.target+".json", to: "manifest.json",force:true }]}),
new ZipPlugin({
path: 'dist/',
filename: PACKAGE.name+"-v"+PACKAGE.version+"-unpacked-release-"+env.target+".zip",
exclude: [/^dist/]
})
]
});