-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
80 lines (77 loc) · 1.97 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
const webpack = require('webpack');
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const devEntry = path.resolve(__dirname, './src/index.tsx');
const prodEntry = {
popup: path.join(__dirname, 'src/popup.tsx'),
content: path.join(__dirname, 'src/content.tsx'),
background: path.join(__dirname, 'src/background.ts'),
};
const config = {
mode: process.env.NODE_ENV ?? 'production',
entry: process.env.NODE_ENV === 'development' ? devEntry : prodEntry,
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
clean: true,
},
module: {
rules: [
{
test: /.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /.ts(x)?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
{
test: /.svg$/,
use: 'file-loader',
},
{
test: /.png$/,
use: [
{
loader: 'url-loader',
options: {
mimetype: 'image/png',
},
},
],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.tsx', '.ts'],
alias: {
'@components': path.resolve(__dirname, 'src/components'),
'@recoil': path.resolve(__dirname, 'src/recoil'),
'@static': path.resolve(__dirname, 'src/static'),
'@lib': path.resolve(__dirname, 'src/lib'),
'@types': path.resolve(__dirname, 'src/types'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@public': path.resolve(__dirname, 'public'),
'@styles': path.resolve(__dirname, 'src/styles'),
},
},
devServer: {
static: './dist',
compress: true,
open: true,
port: 3001,
},
plugins: [
new CopyPlugin({
patterns: [{ from: 'public', to: '.' }],
}),
new HtmlWebpackPlugin({
filename: './public/index.html',
}),
],
devtool: 'source-map',
};
module.exports = config;