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.
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 theindex.html`.
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
publicPathin 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-appand release the built assets in the installation packages, which make it hard to rebuild it with anotherPUBLIC_URL.There are several issues related to this proposal.
Describe the solution you'd like
Currently, the webpack
publicPathfield is decided byPUBLIC_URLand 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-appshould provide another option (maybeWEBPACK_PUBLIC_PATH) to allow user to configpublicPathindependently, and its default value should be 'auto' instead of the value ofPUBLIC_URL.With this all it need to do to apply CDN for built frontend is to replace the
hrefin all<link>and '<script>tags in theindex.html`.