-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
84 lines (82 loc) · 2.25 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
const CopyPlugin = require("copy-webpack-plugin");
const WebExtPlugin = require('web-ext-plugin');
const mode = process.env.NODE_ENV || 'development';
module.exports = {
mode,
entry: {
background: './src/background/main.js',
palette: './src/palette/main.js',
options: './src/options/main.js',
},
output: {
filename: '[name].bundle.js',
path: __dirname + '/dist',
},
module: {
rules: [
{
test: /\.(html|svelte)$/,
exclude: /node_modules/,
use: 'svelte-loader',
},
{
test: /\.m?jsx?$/,
exclude: /node_modules/,
use: 'swc-loader',
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: true
}
},
]
},
{
test: /\.svg$/,
type: 'asset/resource',
use: 'svgo-loader',
}
],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: "./src/palette/index.html",
to: __dirname + "/dist/palette.html",
},
{
from: "./src/palette/static",
to: __dirname + "/dist/palette/static",
},
{
from: "./src/options/index.html",
to: __dirname + "/dist/options.html",
}
]
}),
new WebExtPlugin({
sourceDir: __dirname + '/dist',
buildPackage: true,
overwriteDest: true,
}),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',
minChunks: 2,
},
},
},
},
devtool: mode === 'production' ? undefined : 'inline-source-map'
};