forked from apollographql/apollo-client-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·103 lines (99 loc) · 2.46 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* eslint-disable */
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const WebExtPlugin = require("./WebExtPlugin");
/* eslint-enable */
module.exports = (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({ 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"],
alias: {
"@forked/graphiql": path.resolve(
__dirname,
"node_modules/graphiql-forked/packages/graphiql/dist/index.js"
),
"@forked/graphiql-css": path.resolve(
__dirname,
"node_modules/graphiql-forked/packages/graphiql/graphiql.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,
};
};