Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
104 lines (102 loc) · 3.31 KB
/
Copy pathwebpack.config.js
File metadata and controls
104 lines (102 loc) · 3.31 KB
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
const path = require("path");
const webpack = require("webpack");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const browser = process.env.BROWSER || "chrome";
const isChrome = browser === "chrome";
const outputPath = path.resolve(__dirname, isChrome ? "dist-chrome" : "dist-firefox");
module.exports = {
mode: process.env.NODE_ENV === "production" ? "production" : "development",
devtool: process.env.NODE_ENV === "production" ? false : "inline-source-map",
entry: {
"background/index": "./src/background/index.ts",
"content/index": "./src/content/index.tsx",
"popup/index": "./src/popup/index.tsx",
"options/index": "./src/options/index.tsx",
"login/index": "./src/login/index.tsx",
},
output: {
path: outputPath,
filename: "[name].js",
clean: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
"@shared": path.resolve(__dirname, "src/shared"),
// Force CommonJS version of libsodium (ESM build has missing files)
"libsodium-wrappers-sumo": path.resolve(
__dirname,
"node_modules/libsodium-wrappers-sumo/dist/modules-sumo/libsodium-wrappers.js"
),
},
fallback: {
fs: false,
path: false,
crypto: require.resolve("crypto-browserify"),
buffer: require.resolve("buffer/"),
stream: require.resolve("stream-browserify"),
process: require.resolve("process/browser"),
assert: require.resolve("assert/"),
vm: require.resolve("vm-browserify"),
},
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser",
}),
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new CopyPlugin({
patterns: [
{
from: isChrome
? "manifests/chrome.manifest.json"
: "manifests/firefox.manifest.json",
to: "manifest.json",
},
{
from: "assets",
to: "assets",
},
],
}),
new HtmlWebpackPlugin({
template: "./src/popup/index.html",
filename: "popup/index.html",
chunks: ["popup/index"],
}),
new HtmlWebpackPlugin({
template: "./src/options/index.html",
filename: "options/index.html",
chunks: ["options/index"],
}),
new HtmlWebpackPlugin({
template: "./src/login/index.html",
filename: "login/index.html",
chunks: ["login/index"],
}),
],
performance: {
hints: false,
},
optimization: {
splitChunks: false,
},
};