-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathwebpack.config.js
76 lines (73 loc) · 1.98 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
import path from "path";
import { fileURLToPath } from "url";
import TerserPlugin from "terser-webpack-plugin";
import CopyWebpackPlugin from "copy-webpack-plugin";
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default () => ({
entry: {
background: "./src/background/background",
github: "./src/contentScripts/github",
gitlab: "./src/contentScripts/gitlab",
bitbucket: "./src/contentScripts/bitbucket",
gitee: "./src/contentScripts/gitee",
detectProvider: "./src/contentScripts/detectProvider",
},
output: {
path: path.resolve(__dirname, `dist/${process.env.BROWSER}`),
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
},
{
test: /\.svg$/,
type: "asset/inline",
},
],
},
optimization: {
minimizer: [
new TerserPlugin({
extractComments: false,
terserOptions: {
mangle: false,
compress: {
defaults: false,
unused: true,
arguments: true,
booleans: false,
expression: false,
sequences: false,
join_vars: false,
keep_classnames: true,
keep_fnames: true,
},
format: {
beautify: true,
comments: false,
indent_level: 2,
},
},
}),
],
},
plugins: [
new NodePolyfillPlugin({
additionalAliases: ["url", "process"],
}),
new CopyWebpackPlugin({
patterns: [
{ from: "pages/*", context: "src/" },
{ from: "popups/*", context: "src/" },
{ from: "icons/*", context: "src/assets/" },
{ from: "styles/*", context: "src/assets/" },
{ from: "providers/**/assets/*", context: "src/content/" },
{ from: "manifest.json", context: `src/manifests/${process.env.BROWSER}/` },
],
}),
],
});