Skip to content

Allow user to config publicPath of webpack and set its default value to auto #13642

Open
@link89

Description

@link89

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`.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions