Skip to content
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

What is the difference between using strings and variables when configuring path for dotenv-webpack? #502

Open
haaaafgdbar opened this issue Oct 11, 2023 · 2 comments

Comments

@haaaafgdbar
Copy link

  1. Use variable mode ------------
    const common = require("./webpack.common.js")
    const { merge } = require("webpack-merge")
    const DotEnv = require("dotenv-webpack")
    const webpack = require("webpack")

const DotenvPath = .env.${process.env.NODE_ENV}
console.log(DotenvPath) // .env.dev

module.exports = merge(common, {
plugins: [
new DotEnv({
path: DotenvPath
})
]
})

image

2.use string methods ------------
module.exports = merge(common, {
plugins: [
new DotEnv({
path: “.env.dev”
})
]
})

In this way, the corresponding environment file can be loaded

I'm not sure if I didn't understand the concept clearly or if dotenv-webpack is inherently flawed

@haaaafgdbar
Copy link
Author

@timkelty

@mrsteele
Copy link
Owner

I’m having a hard time following you. Please format your code correctly and I’ll be happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants