-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.mjs
70 lines (65 loc) · 2.38 KB
/
webpack.config.mjs
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
import WebExtPlugin from "web-ext-plugin";
import CopyPlugin from "copy-webpack-plugin";
import {LicenseFilePlugin} from "generate-license-file-webpack-plugin";
import { readFile } from "fs/promises";
import path from "path";
import { Transform } from "stream";
const __dirname = path.resolve();
let pckgJson;
readFile("./package.json").then(data => {
pckgJson = JSON.parse(data);
});
const config = {
entry: {
"background/Background": "/src/background/Background.js",
"settings/Settings": "/src/settings/Settings.js",
"popup/Popup": "/src/popup/Popup.js",
"blocked/Blocked": "/src/blocked/Blocked.js"
},
devtool: "source-map",
output: {
path: __dirname+"/dist",
filename: "[name].js"
},
plugins: [
new CopyPlugin({
patterns: [
{
from: "src/static",
to: "static",
globOptions: {
dot: false,
},
},
{
from: "src/manifest.json",
to: "manifest.json",
transform(content, absoluteFrom) {
content = JSON.parse(content);
content.version = pckgJson.version;
content.description = pckgJson.description;
return JSON.stringify(content, null, 2);
},
},
{ from: "src/popup/Popup.html", to: "popup/Popup.html" },
{ from: "src/popup/Popup.css", to: "popup/Popup.css" },
{ from: "src/blocked/Blocked.html", to: "blocked/Blocked.html"},
{ from: "src/blocked/Blocked.css", to: "blocked/Blocked.css"},
{ from: "src/background/Background.html", to: "background/Background.html" },
{ from: "src/settings/Settings.html", to: "settings/Settings.html" },
{ from: "node_modules/webextension-polyfill/dist/browser-polyfill.js" }
],
}),
new WebExtPlugin({
sourceDir: __dirname+"/dist",
overwriteDest: true,
startUrl: "about:debugging",
browserConsole: true,
devtools: true
}),
new LicenseFilePlugin({
outputFileName: "license-acknowledgements.txt"
})
],
};
export default config;