Skip to content

Webpack PublicPath to be a function #9518

@hitmands

Description

@hitmands

Feature request

The documentation says that __webpack_public_path__ can be overwritten at runtime, something like __webpack_public_path__ = '/www.something.com/.

We could extend this feature by allowing it to be a function:

__webpack_public_path__ = chunk => `www.something.com/${chunk}`

What is the expected behavior?
this would allow webpack to load files from different public paths, depending on the requested chunk.

What is motivation or use case for adding/changing the behavior?
Avoiding unnecessarily client's cache invalidation, further information: https://stackoverflow.com/questions/57337716/webpack-publicpath-use-different-urls-to-reuse-bundles

How should this be implemented in your opinion?
__webpack_public_path__ as a function. It would retrieve the requested chunk as argument and return its absolute path.

Are you willing to work on this yourself?
yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions