-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow to override worker public path #2747
Conversation
@@ -137,7 +137,9 @@ export function pitch(this: LoaderContext<Options>, request: string) { | |||
|
|||
return callback!( | |||
null, | |||
`export default __webpack_public_path__ + ${JSON.stringify(entry)};`, | |||
`export default (typeof __worker_public_path__ != "undefined" ? __worker_public_path__ : __webpack_public_path__) + ${JSON.stringify( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__webpack_public_path__
is guaranteed to exist, but __worker_public_path__
isn't, so we need to check if it exists before accessing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎩 This is working for me. Variable configuration adds flexibility to web workers so the build system can continue using __webpack_public_path__
in other places, undisturbed.
@@ -12,6 +12,7 @@ const moduleWrapperCache = new Map<string, string | false>(); | |||
export interface Options { | |||
name?: string; | |||
wrapperModule?: string; | |||
magicGlobalPathVariable?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking on the name: maybe publicPathGlobal
/ publicPathGlobalVariable
? There isn’t necessarily any magic going on here, it can be any valid JS expression that will resolve to a string at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed it to publicPathGlobalVariable
8781d9e
to
f019b98
Compare
Description
Allows to override
__worker_public_path__
with a plugin option. This is needed for using a custom Extension sandbox URL while not changing other URLs in webpack's build (example).