/
webpack.common.js
69 lines (66 loc) · 1.93 KB
/
webpack.common.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
const path = require("path");
const webpack = require("webpack");
module.exports = {
entry: {
backgroundPage: path.join(__dirname, "src/backgroundPage.ts"),
popup: path.join(__dirname, "src/popup/index.tsx"),
},
output: {
path: path.join(__dirname, "dist/js"),
filename: "[name].js",
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: "ts-loader",
},
// Treat src/css/app.css as a global stylesheet
{
test: /\.css$/,
use: ["style-loader", "css-loader", "postcss-loader"],
},
// Load .module.css files as CSS modules
{
test: /\.module.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
modules: true,
},
},
"postcss-loader",
],
},
// add support for fonts and svg
{
test: /\.(woff|woff2|eot|ttf|otf|svg|gif|png)$/i,
type: "asset/resource",
},
],
},
// Setup @src path resolution for TypeScript files
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
"@src": path.resolve(__dirname, "src/"),
},
fallback: {
"stream": require.resolve("stream-browserify"),
"buffer": require.resolve("buffer")
}
},
plugins: [
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
};