-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
62 lines (60 loc) · 1.53 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
const { CheckerPlugin } = require("awesome-typescript-loader")
const { optimize } = require("webpack")
const { join, resolve } = require("path")
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
const Dotenv = require("dotenv-webpack")
const CopyWebpackPlugin = require("copy-webpack-plugin")
let prodPlugins = []
if (process.env.NODE_ENV === "production") {
prodPlugins.push(new optimize.AggressiveMergingPlugin())
}
module.exports = {
mode: process.env.NODE_ENV,
devtool: "inline-source-map",
entry: {
background: join(__dirname, "src/background/background.ts"),
content: join(__dirname, "src/background/content.ts"),
page: join(__dirname, "src/background/page.ts"),
},
// alias: {
// "@polkadot/wasm-crypto": require.resolve("@polkadot/wasm-crypto/empty"),
// },
output: {
path: join(__dirname, "dist"),
filename: "[name].js",
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.ts?$/,
use: "ts-loader",
},
{
use: { loader: "babel-loader" },
test: /\.(js|jsx)$/,
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts", ".js", ".jsx"],
},
plugins: [
new CheckerPlugin(),
new NodePolyfillPlugin(),
new Dotenv(),
new CopyWebpackPlugin({
patterns: [
{
from: "node_modules/webextension-polyfill/dist/browser-polyfill.js",
},
{
from: "src/popup/public/icons",
to: "icons",
},
],
}),
...prodPlugins,
],
}