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

Change swDest in webpack. #1742

Closed
asolopovas opened this issue Oct 30, 2018 · 4 comments
Closed

Change swDest in webpack. #1742

asolopovas opened this issue Oct 30, 2018 · 4 comments

Comments

@asolopovas
Copy link

Guys I have a question for you, it's great that it is attaching webpack config publicPath. How to operate if I am using something like Wordpress + Webpack + Browser-sync + Workbox? In my case the publicPath: '/wp-content/themes/theme/public/js/' so the default destination of the worker becomes
http://localhost:3000/wp-content/themes/theme/public/js/sw.js so it does not catch any request from root / and pretty much makes it useless. Is there a way around it as if I change swDest: from 'sw.js' to '../sw.js', sw.js disappears and can't be loaded. As WordPress does not store assets inside theme it stores them in /wp-content/uploads/. I could make a symbolic link for service worker inside root directory and link it to theme service worker.js file but it would not work if I use dev server as it stores all assets in memory?

@jadjoubran
Copy link
Collaborator

I don't think anything can be done from Workbox's side. Easiest fix would be to run a copy command after webpack:
cp {fullpath/sw.js} public/

@asolopovas
Copy link
Author

that's an obvious thing to do to "copy it", but that's a wrong thing to do, the best thing would be if swDesk would accept a relative path as then it would be possible to append ../../../

@jeffposnick
Copy link
Contributor

Specifying an absolute path to your desired filesystem directory might work here—it should be supported (#1370).

I can't guarantee that all of the relative paths that are used inside of your service worker to load dependencies like the Workbox library and precache manifest will work as-is—they might also need to be tweaked via the importsDirectory option.

@jeffposnick
Copy link
Contributor

Closing this issue as I'm not sure there's anything more that's actionable here.

If the advice provided doesn't address what you're seeing, please let us know and we can reopen it.

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

No branches or pull requests

3 participants