Skip to content

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

@haaaafgdbar

Description

@haaaafgdbar
  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions