-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathrspack.config.dev.js
More file actions
72 lines (70 loc) · 1.9 KB
/
rspack.config.dev.js
File metadata and controls
72 lines (70 loc) · 1.9 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
const rspack = require('@rspack/core');
const { merge } = require('webpack-merge');
const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
const commonConfig = require('./rspack.config.common');
module.exports = merge(commonConfig, {
mode: 'development',
devServer: {
server: 'https',
host: 'localhost',
port: process.env.PORT_APP || '3001',
hot: true,
client: {
overlay: false,
},
// ngrok tunnel
allowedHosts: ['.ngrok-free.app'],
headers: {
'Access-Control-Allow-Origin': '*',
},
historyApiFallback: true,
// Fix .ts worker files served with video/mp2t MIME type
setupMiddlewares: (middlewares, devServer) => {
devServer.app.use((req, res, next) => {
if (req.url.endsWith('.ts') || req.url.match(/\.ts\?/)) {
res.setHeader('Content-Type', 'application/javascript');
}
next();
});
return middlewares;
},
},
module: {
rules: [
{
test: /\.[jt]sx?$/,
exclude: [/node_modules/, /\/workers\/(?:background|db)\/worker\.ts$/],
include: [/src/, /netlify\/mocks/],
use: {
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
refresh: true,
},
},
},
env: {
targets: 'chrome >= 87, firefox >= 78, safari >= 14, edge >= 88',
},
},
},
},
],
},
plugins: [
new ReactRefreshPlugin({ overlay: false }),
new rspack.DefinePlugin({
...commonConfig.plugins.find(
(plugin) => plugin.constructor.name === 'DefinePlugin'
).definitions,
'process.env.IS_DEV': JSON.stringify(true),
}),
],
});