Comments (9)
alright, cool, thank you @mrsteele!
from dotenv-webpack.
Feel free to simply remove the safe
param. This would remove the safety checks since you just want to use the variables provided by your .env
file.
from dotenv-webpack.
Just to make sure I understand, you have something similar to:
// webpack.config.js
const Dotenv = require('dotenv-webpack');
const { DefinePlugin } = require('webpack');
module.exports = {
...
plugins: [
new DefinePlugin({
// ...
}),
new Dotenv({
path: './.my.env', // if not simply .env
safe: true // lets load the .env.example file as well
})
]
...
};
Can you tell me exactly what error / unexpected behavior occurs with this?
from dotenv-webpack.
Yes, sorry I didn't include any examples, something like this:
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new dotEnv({
path: './env',
safe: './env',
}),
I use the same path for safe
and path
because I don't use a .env.example
file.
from dotenv-webpack.
Okay, looking at your example, i'm betting the following is happening:
If you look at this line:
https://github.com/mrsteele/dotenv-webpack/blob/master/src/index.js#L51
You will see I am assigning a variable like you on process.env
.
Since you just have the one, have you tried changing your DefinePlugin to use?:
new webpack.DefinePlugin({
'process.env.NODE_ENV': "production"
}),
new dotEnv({
path: './env',
safe: './env',
}),
This should help in the definition phase.
from dotenv-webpack.
Although that wouldn't explain why it all worked as expected when you did one before the other... Are you sure it all worked when you changed the order?
from dotenv-webpack.
I'm gonna try what you just said, that does make sense.
Yes, it is running on production already. :)
from dotenv-webpack.
@mrsteele: it works in the way that you just said.
I guess webpack.DefinePlugin
has an incremental way of defining new env vars.
from dotenv-webpack.
Yeah, sorry about the issues but if anything maybe a good idea to open an issue with the DefinePlugin
with webpack.
from dotenv-webpack.
Related Issues (20)
- Restrict to prefix like CRA does with REACT_APP_x HOT 2
- Look into runtime variables
- 'process' is not defined. HOT 2
- Using the plugin with Cloudflare Workers throws an error HOT 5
- Uncaught ReferenceError: process is not defined HOT 4
- Support import.meta.env as an alternative to process.env HOT 3
- i'm not able to access .env variables please help me thanks in advance. HOT 5
- Mandatory process.env.NODE_ENV replacement HOT 2
- Got MISSING_ENV_VAR Even though it's already configured in webpack HOT 4
- Can't make dotenv-webpack work when using webpack-merge HOT 5
- Facing issue with accessing environment variables. My configurations are: HOT 3
- systemvars not trumping .env vars HOT 2
- ... sorry HOT 1
- How to set multiline variables? HOT 3
- dotenv-webpack not working. env file not loaded. variables are undefined HOT 4
- How to use the prefix param properly? HOT 5
- bumb dotenv-defaults HOT 2
- process is not defined HOT 9
- What is the difference between using strings and variables when configuring path for dotenv-webpack? HOT 2
- Env variables not accessible in webpack config HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotenv-webpack.