-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.js
69 lines (68 loc) · 2.03 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 Dotenv = require("dotenv-webpack");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: {
backgroundScript: path.join(__dirname, "src/backgroundScript.ts"),
contentScript: path.join(__dirname, "src/contentScript.tsx"),
customApp: path.join(__dirname, "src/custom-app/index.tsx"),
popup: path.join(__dirname, "src/popup/index.tsx"),
sidebar: path.join(__dirname, "src/sidebar/index.tsx"),
devtool: path.join(__dirname, "src/devtool/index.tsx")
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
publicPath: ""
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: "ts-loader",
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource'
}
],
},
plugins: [
new Dotenv(),
new CopyPlugin({
patterns: [
'src/manifest.json',
'src/rules.json'
]
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'views', 'popup.html'),
inject: 'body',
chunks: ['popup'],
hash: true,
filename: 'popup.html'
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'views', 'sidebar.html'),
inject: 'body',
chunks: ['sidebar'],
hash: true,
filename: 'sidebar.html'
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'views', 'devtool.html'),
inject: 'body',
chunks: ['devtool'],
hash: true,
filename: 'devtool.html'
})
],
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
"@src": path.resolve(__dirname, "src/"),
},
},
};