-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
103 lines (98 loc) · 2.67 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const path = require( 'path' );
const defaultRewrite = function ( path, req ) {
return '/index.html';
};
const assetsRewrite = function ( path, req ) {
if (
path.match( '/assets/theme-light.css' ) ||
path.match( '/assets/theme-dark.css' ) ||
path.match( '/assets/theme-light.map' ) ||
path.match( '/assets/theme-dark.map' )
) {
return path.replace( '/assets', '' );
}
const matches = path.match( /\/.+?(\/.*)/ );
return matches[ 1 ];
};
module.exports = {
entry: './app/index.jsx',
mode: 'development',
module: {
rules: [
{
exclude: /(node_modules)/,
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/env',
'@babel/react',
],
},
},
},
],
},
devtool: 'source-map',
devServer: {
https: true,
host: '0.0.0.0',
port: 9000,
devMiddleware: {
publicPath: "https://0.0.0.0:9000/scripts/",
},
static: {
directory: path.join( __dirname, 'dev' ),
watch: true,
},
proxy: {
'/*/*.html': {
target: 'https://0.0.0.0:9000',
secure: false,
pathRewrite: defaultRewrite,
},
'/*/': {
target: 'https://0.0.0.0:9000',
secure: false,
pathRewrite: defaultRewrite,
},
'/*/assets/**': {
target: 'https://0.0.0.0:9000',
secure: false,
pathRewrite: assetsRewrite,
},
'/*/scripts/dev.js': {
target: 'https://0.0.0.0:9000',
secure: false,
pathRewrite: {
'^/.*/scripts': '/assets'
},
},
'/scripts/dev.js': {
target: 'https://0.0.0.0:9000',
secure: false,
pathRewrite: {
'^/scripts': '/assets'
},
},
'/*/scripts/app.js': {
target: 'https://0.0.0.0:9000',
secure: false,
pathRewrite: {
'^/.*/scripts': '/scripts'
},
},
},
},
output: {
filename: 'app.js',
path: path.resolve( __dirname, 'web/scripts' ),
},
resolve: {
extensions: [
'.js',
'.jsx',
],
},
};