-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
116 lines (112 loc) · 2.92 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
104
105
106
107
108
109
110
111
112
113
114
115
116
const path = require("path");
const { IgnorePlugin } = require("webpack");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const IN_DEVELOPMENT = process.env.NODE_ENV !== "production";
const config = {
target: "web",
cache: false,
entry: {
index: path.join(__dirname, "./src/index.tsx"),
background: path.join(__dirname, "./src/background.ts"),
contentscript: path.join(__dirname, "./src/contentscript.ts"),
inpage: path.join(__dirname, "./src/inpage.ts"),
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
clean: true,
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
plugins: [new TsconfigPathsPlugin()],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: ["babel-loader", "@linaria/webpack-loader"],
exclude: /node_modules/,
},
{
test: /\.svg$/,
use: ["@svgr/webpack", "svgo-loader"],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
url: false,
sourceMap: IN_DEVELOPMENT,
},
},
],
},
],
},
plugins: [
new IgnorePlugin({
resourceRegExp: /^ws$/,
}),
new MiniCssExtractPlugin({
filename: "styles.css",
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.join(__dirname, "./node_modules/beam-wasm-client-masternet/"),
globOptions: {
ignore: ["package.json"],
},
},
{
from: path.join(__dirname, "src/assets"),
to: path.join(__dirname, "dist/assets"),
context: "public",
},
{
from: path.join(__dirname, "src/page.html"),
to: path.join(__dirname, "dist"),
context: "public",
},
{
from: path.join(__dirname, "src/notification.html"),
to: path.join(__dirname, "dist"),
context: "public",
},
{
from: path.join(__dirname, "src/popup.html"),
to: path.join(__dirname, "dist"),
context: "public",
},
{
from: path.join(__dirname, "src/background.html"),
to: path.join(__dirname, "dist"),
context: "public",
},
{
from: path.join(__dirname, "src/manifest.json"),
to: path.join(__dirname, "dist/manifest.json"),
context: "public",
},
],
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
],
externals: ["fs"],
};
module.exports = (env, argv) => {
if (argv.mode === "development") {
config.devtool = "inline-source-map";
}
return config;
};