Skip to content

Commit

Permalink
Update env.md documentation (rails#2630)
Browse files Browse the repository at this point in the history
While trying to get a clean Rails + Webpacker project going with `dotenv` I noticed that my environment variables weren't being picked up by webpack, even after following this doc. Adding these lines to my `environment.js` file fixes the issue.

While I think there's a plugin like this in the default plugins, I have the feeling that changes to `process.env` made by `dotenv` are not being picked up in that plugin, which is why I think we need to redefine the plugin after we call `dotenv.config`.
  • Loading branch information
RSO authored Jun 17, 2020
1 parent 12971d5 commit 830f476
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ dotenvFiles.forEach((dotenvFile) => {
dotenv.config({ path: dotenvFile, silent: true })
})

environment.plugins.insert(
"Environment",
new webpack.EnvironmentPlugin(process.env)
)

module.exports = environment
```

Expand Down

0 comments on commit 830f476

Please sign in to comment.