Skip to content

Allow public path to be a function #18895

@Jack-Works

Description

@Jack-Works

Feature request

Allow the public path to be a function.

What is the expected behavior?

It should call the function everytime instead of +.

What is motivation or use case for adding/changing the behavior?

https://developer.chrome.com/docs/extensions/reference/manifest/web-accessible-resources

There is an option called "use_dynamic_url" in Chrome extension.

Normally, resources can be accessed via URLs like chrome-extension://odhaijconicohjickedigmojjmeblalp/my-file.js, but with this option on (this options improves security and privacy), it has to be chrome.runtime.getURL('my-file.js'), and the return URL becomes chrome-extension://21f06455-6875-452b-8132-01268c50ba0e/my-file.js where the UUID is random every time.

It will be easier to support this use case in a plugin (awesome-webextension/webpack-target-webextension#47) if the public path can be a function.

How should this be implemented in your opinion?

Add a new webpack internal function:

__webpack__require__.xxx = function (path) {
    if (typeof __webpack_require__.p == 'function') return __webpack_require__.p(path)
    return __webpack_require.p + path
}

And replace all direct use of RuntimeGlobals.publicPath to call this helper function.

Are you willing to work on this yourself?
yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Priority - Low

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions