@@ -22,7 +22,14 @@ var paths = require('./paths');
22
22
23
23
// Webpack uses `publicPath` to determine where the app is being served from.
24
24
// In development, we always serve from the root. This makes config easier.
25
- var publicPath = '/' ;
25
+ // ZEAL: Setting publicPath in the start script and passing it in. Since we are
26
+ // mounting this app on various backends, the dev server port will be different
27
+ // from the port on window location. Because of this, we need the full public
28
+ // path, not just the relative path. Elements of the full path can be dynamic,
29
+ // but are all known in the start script, making it the best place to define the
30
+ // public path.
31
+ // var publicPath = '/';
32
+
26
33
// `publicUrl` is just like `publicPath`, but we will provide it to our app
27
34
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
28
35
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
@@ -33,7 +40,9 @@ var env = getClientEnvironment(publicUrl);
33
40
// This is the development configuration.
34
41
// It is focused on developer experience and fast rebuilds.
35
42
// The production configuration is different and lives in a separate file.
36
- module . exports = {
43
+ // ZEAL: Converted to a function to allow injecting the publicPath.
44
+ module . exports = function ( publicPath ) {
45
+ return {
37
46
// This makes the bundle appear split into separate modules in the devtools.
38
47
// We don't use source maps here because they can be confusing:
39
48
// https://github.com/facebookincubator/create-react-app/issues/343#issuecomment-237241875
@@ -51,9 +60,12 @@ module.exports = {
51
60
// Note: instead of the default WebpackDevServer client, we use a custom one
52
61
// to bring better experience for Create React App users. You can replace
53
62
// the line below with these two lines if you prefer the stock client:
54
- // require.resolve('webpack-dev-server/client') + '?/',
55
- // require.resolve('webpack/hot/dev-server'),
56
- require . resolve ( 'react-dev-utils/webpackHotDevClient' ) ,
63
+ // ZEAL: Opted to use the default client because the custom one gets the
64
+ // port off window location, which will be different from the dev server
65
+ // when the app is served from a different back end.
66
+ require . resolve ( 'webpack-dev-server/client' ) + '?' + publicPath ,
67
+ require . resolve ( 'webpack/hot/dev-server' ) ,
68
+ // require.resolve('react-dev-utils/webpackHotDevClient'),
57
69
// We ship a few polyfills by default:
58
70
require . resolve ( './polyfills' ) ,
59
71
// Finally, this is your app's code:
@@ -221,4 +233,4 @@ module.exports = {
221
233
net : 'empty' ,
222
234
tls : 'empty'
223
235
}
224
- } ;
236
+ } } ;
0 commit comments