forked from SoulWallet/soul-wallet-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
61 lines (60 loc) · 1.83 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
const path = require("path");
const DotEnv = require("dotenv-webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
module.exports = {
entry: {
background: path.join(__dirname, "src/background.ts"),
contentScripts: path.join(__dirname, "src/contentScripts.ts"),
inpage: path.join(__dirname, "src/inpage.ts"),
// inject2: path.join(__dirname, "src/inject2.ts"),
popup: path.join(__dirname, "src/popup/index.tsx"),
},
output: {
path: path.join(__dirname, "dist/js"),
filename: "[name].js",
},
plugins: [new NodePolyfillPlugin(), new DotEnv()],
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"],
},
// 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: {
fs: false,
},
},
};