forked from apollographql/apollo-client-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.mjs
executable file
·102 lines (97 loc) · 2.35 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
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
101
102
import path from 'path';
import url from 'url';
import CopyPlugin from 'copy-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import WebExtPlugin from 'web-ext-plugin';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
export default (env) => {
const devOptions =
env.NODE_ENV === "development"
? {
devtool: "inline-source-map",
}
: {};
const plugins = [
new CopyPlugin({
patterns: [
{
from: "./src/extension/devtools/panel.html",
to: path.resolve(__dirname, "build"),
},
{
from: "./src/extension/devtools/devtools.html",
to: path.resolve(__dirname, "build"),
},
{
from: "./src/extension/images",
to: path.resolve(__dirname, "build/images"),
},
{
from: "./src/extension/manifest.json",
to: path.resolve(__dirname, "build"),
},
],
}),
];
if (env.NODE_ENV === "development") {
plugins.push(
new WebExtPlugin({
browserConsole: true,
runLint: false,
sourceDir: path.resolve(__dirname, 'build'),
startUrl: 'http://localhost:3000',
target: env.TARGET,
})
);
}
return {
...devOptions,
mode: env.NODE_ENV,
entry: {
panel: "./src/extension/devtools/panel.ts",
background: "./src/extension/background/background.ts",
devtools: "./src/extension/devtools/devtools.ts",
tab: "./src/extension/tab/tab.ts",
hook: "./src/extension/tab/hook.ts",
},
output: {
path: path.join(__dirname, "build"),
filename: "[name].js",
},
resolve: {
extensions: [".mjs", ".js", ".ts", ".tsx", ".css"],
},
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.(ts)x?$/,
loader: "ts-loader",
},
],
},
optimization: {
minimize: env.NODE_ENV === "production",
minimizer: [
new TerserPlugin({
terserOptions: {
output: {
comments: false,
},
},
extractComments: false,
}),
],
},
plugins,
};
};