-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.dev.config.js
99 lines (97 loc) · 2.67 KB
/
webpack.dev.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
import { merge } from 'webpack-merge';
import commonConfig from './webpack.config.js';
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { config } from '@dotenvx/dotenvx';
config();
const DEV_SERVER_PORT = 8080;
export default merge(commonConfig, {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
historyApiFallback: true,
port: DEV_SERVER_PORT,
hot: true,
server: 'https',
proxy: [
{
context: (path) => path.includes('/oauth2/'),
target: process.env.AUTH_URL,
secure: false,
changeOrigin: true,
autoRewrite: false,
toProxy: true,
headers: {
'X-Forwarded-Host': `localhost:${DEV_SERVER_PORT}`,
},
onProxyRes: (proxyRes) => {
const location = proxyRes.headers['location'];
if (location) {
proxyRes.headers['location'] = location.replace(
'konflux-ui.apps.stone-stg-rh01.l2vh.p1.openshiftapps.com%2Foauth2',
`localhost:${DEV_SERVER_PORT}/oauth2`,
);
}
},
},
{
context: (path) => path.includes('/api/k8s/registration'),
target: process.env.REGISTRATION_URL,
secure: false,
changeOrigin: true,
autoRewrite: true,
ws: true,
toProxy: true,
// pathRewrite: { '^/api/k8s/registration': '' },
},
{
context: (path) => path.includes('/api/k8s'),
target: process.env.PROXY_URL,
secure: false,
changeOrigin: true,
autoRewrite: true,
ws: true,
toProxy: true,
// pathRewrite: { '^/api/k8s': '' },
},
{
context: (path) => path.includes('/wss/k8s'),
target: process.env.PROXY_WEBSOCKET_URL,
secure: false,
changeOrigin: true,
autoRewrite: true,
ws: true,
toProxy: true,
// pathRewrite: { '^/wss/k8s': '' },
},
],
},
module: {
rules: [
{
test: /\.s?[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.[jt]sx?$/i,
exclude: /(node_modules)/,
use: [
{
loader: 'swc-loader',
options: {
jsc: {
transform: {
react: {
development: true,
refresh: true,
},
},
},
},
},
],
},
],
},
plugins: [new ReactRefreshWebpackPlugin(), new ForkTsCheckerWebpackPlugin({ devServer: false })],
});