Description
Is your proposal related to a problem?
It's popular to use CDN when deploy a web app to production, while in test stage the static assets are served with a file server or s3. In most case this can be done by building app multiple time with different PUBLIC_URL
.
But there are some case that will need to change publicPath
in the runtime.
One case is serving built vendor frontend assets without source code.
The typical case make me want this feature is streamlit and its compoments. Their frontend code is built with create-react-app
and release the built assets in the installation packages, which make it hard to rebuild it with another PUBLIC_URL
.
There are several issues related to this proposal.
- Set 'currentScript' as default 'PUBLIC_URL' #3834
- Does __webpack_public_path__ accept "auto"? #13467
- https://stackoverflow.com/questions/59034660/how-to-change-the-publicpath-in-create-react-app
Describe the solution you'd like
Currently, the webpack publicPath
field is decided by PUBLIC_URL
and it's hard to modify the webpack configuration.
In order to make it easier to apply CDN in the mentioned case,
I think create-react-app
should provide another option (maybe WEBPACK_PUBLIC_PATH
) to allow user to config publicPath
independently, and its default value should be 'auto' instead of the value of PUBLIC_URL
.
With this all it need to do to apply CDN for built frontend is to replace the href
in all <link>
and '<script>tags in the
index.html`.