-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
46 lines (42 loc) · 1.1 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
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
/**
* @type import("webpack").Configuration
*/
const config = {
entry: {
background: path.join(__dirname, "src/background.ts"),
content: path.join(__dirname, "src/content.ts"),
popup: path.join(__dirname, "src/popup.tsx"),
},
output: {
path: path.join(__dirname, "dist"),
filename: "scripts/[name].js",
},
module: {
rules: [
{
test: /\.tsx?$/,
use: { loader: "ts-loader", options: { transpileOnly: true } },
exclude: [/node_modules/, "/**/*.test.ts"],
},
],
},
resolve: { extensions: [".js", ".ts", ".tsx"], modules: ["node_modules"] },
plugins: [
new CopyPlugin({
patterns: [
{ from: "./src/static", to: "./" },
{ from: "./src/locales", to: "./_locales" },
{ from: "./src/images", to: "./images" },
],
}),
],
};
module.exports = (_env, argv) => {
if (argv.mode === "development") {
config.devtool = "inline-source-map";
}
config.optimization = { minimize: argv.mode === "production" };
return config;
};