[feature] make it work with dotenv-webpack
See original GitHub issueLibrary Affected: workbox-webpack-plugin
Browser & Platform: all browsers
Issue or Feature Request Description: it should work with dotenv-webpack or other way to inject environment variables
Use case: I’d like to change firebase config based on .env
const config = {
messagingSenderId: process.env.FIREBASE_MESSAGING_SEND_ID,
};
firebase.initializeApp(config);
but process
is undefined on sw.js
I’m using workboxPlugin.InjectManifest
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
dotenv-webpack - npm
A secure webpack plugin that supports dotenv and other environment variables and only exposes what you choose and use. npm codecov Main ...
Read more >Using environment variables with Webpack - Prateek Surana
A guide for setting up and using environment variables with Webpack and handling different values for Production and Development ...
Read more >Dotenv-webpack in production? - Stack Overflow
My .env file looks something like: SECRET_KEY=123456 In my Heroku Dashboard I have key set to SECRET_KEY and value set to 123456. Does...
Read more >Environment Variables - webpack
The webpack command line environment option --env allows you to pass in as many environment variables as you like. Environment variables will be...
Read more >Using environment variables in React | by Sam Pakvis - Medium
Now, run your npm run dev command, go to your React component and use the ... Dotenv is commonly used (create-react-app uses it,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be addressed by https://github.com/GoogleChrome/workbox/releases/tag/v5.0.0-alpha.0
It will compile you
swSrc
, and if you need to pass in specific plugins to configure the webpack compilation (like a plugin to handle that replacement), you should be able to do that via the newwebpackCompilationPlugins
configuration option.Please reopen if I’m misinterpreting your use case, and you’re still unable to accomplish that.
You’ll need some sort of build tool to replace the environment variable placeholders with their actual values. If you don’t use
webpack
, you’ll have to use something else, most likely something from https://bundlers.tooling.report/