-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.dev.ts
119 lines (112 loc) · 3.09 KB
/
webpack.dev.ts
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
112
113
114
115
116
117
118
119
/* eslint-disable no-magic-numbers, no-console */
/**
* Webpack development server configuration
*
* This file is set up for serving the webpack-dev-server, which will watch for changes and recompile as required if
* the subfolder /webpack-dev-server/ is visited. Visiting the root will not automatically reload.
* */
import 'webpack-dev-server';
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import path from 'path';
import webpack from 'webpack';
import merge from 'webpack-merge';
import { ConfigurationPlugin } from './scripts/webpack/ConfigurationPlugin';
import common from './webpack.common';
const config: webpack.Configuration = merge(common, {
mode: 'development',
devtool: 'eval-cheap-module-source-map',
cache: true,
stats: {
colors: true,
reasons: true,
logging: 'info',
},
infrastructureLogging: {
level: 'log',
},
output: {
filename: 'assets/[name].js',
},
devServer: {
static: { directory: path.join(__dirname, 'src'), watch: false },
hot: true,
port: 7000,
host: 'localhost',
historyApiFallback: {
index: '/',
disableDotRule: true,
},
// used for app catalogs proxy /catalogs?url=
proxy: {
'/catalogs': {
target: 'https://cors-anywhere.herokuapp.com/',
changeOrigin: true,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onProxyReq: (proxyReq: Record<string, any>) => {
const wantedUrl = proxyReq.path.substr(
(proxyReq.path as string).indexOf('?url=') + 5
);
proxyReq.path = `/${wantedUrl}`;
proxyReq.setHeader('origin', 'http://localhost:7000');
},
},
},
},
plugins: [
new ConfigurationPlugin({
filename: 'index.ejs',
outputFilename: 'index.html',
overrides: {
apiEndpoint: 'http://localhost:8000',
mapiEndpoint: 'http://localhost:8888',
athenaEndpoint: 'http://localhost:7777',
mapiAudience: 'http://localhost:9999',
mapiAuthRedirectURL: 'http://localhost:7000',
environment: 'development',
happaVersion: 'development',
},
proxies: [
{
port: 8000,
host: (options) => options.apiEndpoint,
},
{
port: 8888,
host: (options) => options.mapiEndpoint,
},
{
port: 7777,
host: (options) => options.athenaEndpoint,
},
{
port: 9999,
host: (options) => {
if (!/http(s)?:\/\//.test(options.mapiAudience)) {
return `https://${options.mapiAudience}`;
}
return options.mapiAudience;
},
},
],
}),
new ReactRefreshWebpackPlugin(),
],
module: {
rules: [
{
test: /\.(js|ts)(x?)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.sass$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
});
export default config;