-
Notifications
You must be signed in to change notification settings - Fork 823
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
how to use env variables in SW for Workbox 5 #2410
Comments
My understanding is that webpack child compilers (which the @jeffposnick, can you confirm? If so, would it be possible to add an option to @novaknole, another option you can do now would be to compile your service worker separately from the rest of your app. There's some guidance on how to do that here: https://developers.google.com/web/tools/workbox/guides/using-bundlers |
I have @jeffposnick shoot some ideas . Thanks both of you. |
Regarding question 1, as soon as #2400 is deployed in the next Workbox release, using (I am working on fixes for #2383 and #2399 that I'd also like to ship in the next release, but if that ends up taking too long, maybe we could ship Regarding question 2, if you write your
This works exactly the same as consuming the Workbox runtime modules works in v5. |
(Also, before #2400 ships, you should be able to put your environment variables into a dedicated chunk that is compiled by the main |
Hey @jeffposnick , do you have an approximate timeframe for when #2400 will be released as this will determine what solution I will implement now based on whether or not i should wait or not. Thanks ! ! ! |
This is now available in the |
Library Affected:
const { InjectManifest } = require('workbox-webpack-plugin');.
Browser & Platform:
Issue or Feature Request Description:
I am using workbox-webpack-plugin 5.0.0
Question 1)
Now, In my project, I have a
index.js
file looking like this:and let's take a look of one of the files
app: require('./app')
what I now need is to use those variables in my service worker file. I can't import
index.js
file since I don't copy/paste it viacopy-webpack-plugin
. What other ideas do you have on your mind, Jeff ? I tried:but when I console
process.env
in service-worker, It's an empty object.What do I do ? @jeffposnick
Question 2)
In my sw.js, I have this:
I am thinking about a new way of including these in my sw.js.
idb.min.js
is already compiled which is great, but myutility.js
is not compiled which makes me worried. Is there any way I don't import those scripts, but somehow by usinginjectmanifest
plugin, i can still compile and include it somehow in my final bundled sw.js?The text was updated successfully, but these errors were encountered: