-
-
Notifications
You must be signed in to change notification settings - Fork 273
Issue with publicPath in v3 #281
Comments
You need rewrite |
Previous implementation was wrong and doesn't work with |
Using |
It is only working solution in your case, |
Also you do not fill out the issue template and without reproducible test repo or steps, I can't say you the best solution |
@evilebottnawi Should the Cross-Origin Policy section update for v3. I meet the Cross-Origin Policy problem, and set the publicPath option as the readme said module.exports = {
module: {
rules: [
{
loader: 'worker-loader',
options: { publicPath: '/workers/' },
},
],
},
}; But it is not work for v3, which (the same publicPath setting) work for v2. |
@clinyong Can you provide reproducible test repo? it is tested and works fine |
the publicPath option does't work at all, it always use out.publicPath to require my js, if it's the original purpose, I have to go back to v2 |
@clinyong I think here we have misleading docs, in fact we have two
Why? Because there are 2 cases:
|
In this case you need override public path on fly: index.js import './rewritePublicPath';
import EchoWorker from "./echo.worker";
const echoWorker = new EchoWorker();
echoWorker.onmessage = function (e) {
console.log("Message received from worker");
console.log(e.data);
};
setTimeout(() => {
console.log("Post message to worker");
echoWorker.postMessage([1, 2]);
}, 1000); rewritePublicPath.js // You can use `Define` plugin to avoid hardcodding value to code
__webpack_public_path__ = "http://127.0.0.1:5000/dist/"; |
But maybe we can introduce |
I think we can improve |
@evilebottnawi This would be awesome. Any news on the fix for this? |
You can find PR above your comment |
Expected Behavior
I would expect that setting publicPath in options would take precedence over
__webpack_public_path__
variable.We use webpacker and setting a CDN path to serve our assets. However, worker must be served from same domain in order to work.
I had to use patch-package to revert to one of previous versions and fit it my needs (code below).
Actual Behavior
With our setup, passing
publicPath
does nothing.Code
patch-package snippet
The text was updated successfully, but these errors were encountered: