question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] make it work with dotenv-webpack

See original GitHub issue

Library 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jeffposnickcommented, Jul 18, 2019

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 new webpackCompilationPlugins configuration option.

Please reopen if I’m misinterpreting your use case, and you’re still unable to accomplish that.

1reaction
jeffposnickcommented, May 14, 2021

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/

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found