-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
80 lines (79 loc) · 2.23 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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
mode: process.env.NODE_ENV === "development" ? "development" : "production",
devtool:
// DevTools page doesn't support separated source-map yet.
// Use inline-source-map in development only.
process.env.NODE_ENV === "development" ? "inline-source-map" : undefined,
context: __dirname,
entry: {
devtools: "./src/devtools",
panel: "./src/panel",
background: "./src/background",
content: "./src/content",
hook: "./src/hook",
},
output: {
path: path.join(__dirname, "extension/build"),
filename: "[name].js",
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
symlinks: false,
},
module: {
rules: [
{
// Include ts, tsx, js, and jsx files.
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: "babel-loader",
// Todo(steve): remove these plugins after update webpack@5
// Ref https://github.com/webpack/webpack/issues/10227
options: {
plugins: [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
],
},
},
{
test: /\.css$/,
// Ref https://github.com/webpack-contrib/mini-css-extract-plugin/issues/118
sideEffects: true,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.(woff(2)?|ttf|eot)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
// publicPath: distPublicPath
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
new HtmlWebpackPlugin({
title: "Brick Next Developer Tools Panel",
chunks: ["panel"],
filename: "panel.html",
}),
new HtmlWebpackPlugin({
title: "Brick Next Developer Tools",
chunks: ["devtools"],
filename: "devtools.html",
}),
new MiniCssExtractPlugin(),
],
};