-
Notifications
You must be signed in to change notification settings - Fork 189
/
webpack.config.js
111 lines (103 loc) · 2.72 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
import CopyWebpackPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import { fileURLToPath } from 'url';
import path from 'path';
import webpack from 'webpack';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const tsloader = {
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
projectReferences: true,
},
};
const common = {
output: {
path: path.resolve('dist'),
},
context: __dirname,
mode: 'production',
optimization: {
minimize: false,
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
})
]
};
const background = {
...common,
entry: {
background: path.resolve('src/background/index.ts'),
},
externals: { crypto: 'null' },
module: {
rules: [tsloader],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
// 'buffer': buffer,
// 'stream': streamBrowserify,
},
},
};
const blindrsa = {
...common,
entry: {
blindrsa: path.resolve('src/blindrsa/index.ts'),
},
externals: { crypto: 'null' },
module: {
rules: [tsloader],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
// 'buffer': buffer,
// 'stream': streamBrowserify,
},
},
};
const popup = {
...common,
entry: {
popup: path.resolve('src/popup/index.tsx'),
},
module: {
rules: [
tsloader,
{
test: /\.scss?$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{ test: /\.(png|jpe?g|gif|svg)$/, use: 'file-loader' },
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.scss', '.json', '.svg', '.html'],
plugins: [
new TsconfigPathsPlugin({
extensions: ['.tsx', '.ts', '.js', '.scss', '.json', '.svg', '.html'],
configFile: 'src/popup/tsconfig.json',
}),
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: 'public/icons', to: 'icons' }, { from: 'public/manifest.json' }],
}),
new HtmlWebpackPlugin({
chunks: ['popup'],
filename: 'popup.html',
template: 'public/popup.html',
}),
new MiniCssExtractPlugin(),
],
};
// Mutiple targets for webpack: https://webpack.js.org/concepts/targets/#multiple-targets
export default [blindrsa, background, popup];