-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
100 lines (98 loc) · 2.47 KB
/
webpack.dev.config.js
File metadata and controls
100 lines (98 loc) · 2.47 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
mode: 'development',
entry: {
sidepanel: './src/sidepanel.tsx',
},
output: {
path: path.resolve(__dirname, 'dev-dist'),
filename: '[name].js',
publicPath: '/',
clean: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true, // Faster compilation for HMR
},
},
exclude: [/node_modules/, /\.test\.tsx?$/],
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
url: {
filter: (url) => {
// Don't process font URLs - they're handled by CopyPlugin
return !url.includes('fonts/');
}
}
}
},
'postcss-loader'
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/sidepanel.html',
inject: 'body',
scriptLoading: 'blocking',
filename: 'sidepanel.html',
}),
new CopyPlugin({
patterns: [
{ from: 'public/manifest.json', to: 'manifest.json', noErrorOnMissing: true },
{ from: 'assets/media', to: 'assets/media', noErrorOnMissing: true },
{ from: 'assets/fonts', to: 'assets/fonts', noErrorOnMissing: true },
{ from: 'assets/files', to: 'assets/files', noErrorOnMissing: true },
{ from: 'assets/icons', to: 'assets/icons', noErrorOnMissing: true },
{ from: 'src/lib/thm-docs', to: 'lib/thm-docs', noErrorOnMissing: true }
]
})
],
devServer: {
static: [
{
directory: path.join(__dirname, 'assets'),
publicPath: '/assets',
},
{
directory: path.join(__dirname, 'src/lib/thm-docs'),
publicPath: '/lib/thm-docs',
}
],
port: 3000,
hot: true,
liveReload: false, // Use HMR instead
open: ['sidepanel.html'],
compress: true,
historyApiFallback: {
index: '/sidepanel.html',
},
client: {
overlay: {
errors: true,
warnings: false,
},
},
},
devtool: 'eval-source-map', // Better for HMR
optimization: {
runtimeChunk: 'single', // Better HMR performance
},
};