Skip to content
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

put worker scripts into index.html at build time #28

Open
magdasmircea opened this issue Sep 8, 2020 · 1 comment
Open

put worker scripts into index.html at build time #28

magdasmircea opened this issue Sep 8, 2020 · 1 comment

Comments

@magdasmircea
Copy link

magdasmircea commented Sep 8, 2020

Hi there,

is there an option to put the generated scripts for the workers inside index.html at build time? we use publicPath="#CDN#" and this placeholder is replaced when the server parses the generated index.html with a cdn url that i cannot know at build time. So my config looks :

config.module .rule("comlink worker") .test(/\.worker\.js$/i) .use("comlink") .loader("comlink-loader") .options({ singleton: true, name:staticV2/${buildNum}/js/[name].[hash:8].[ext] }) .end();

and it looks like this workers files are bundled in another script like so: return new Worker(r.p+"staticV2/TAG/js/formParser.worker.ea9dda30.js")}}

so this means that the server wont be able to replace that #CDN# placeholder and will result in an invalid path for this resource. e.g: #CDN#/staticV2/TAG/js/formParser.worker.ea9dda30.js'
I have tried to pass an option publicPath: "" at least to try to load them from the actual server that makes the initial GET but no success.

Is there a solution you can suggest for my use case?
Thanks

@magdasmircea
Copy link
Author

GoogleChromeLabs/worker-plugin#36 this issue sums up exactly what i wanted to achieve with comlink-loader. I get the same error : Uncaught DOMException: Failed to construct 'Worker': Script at [cdndomain/scriptName] cannot be accessed from origin [url]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant