Skip to content

dotenv-webpack not working. env file not loaded. variables are undefined #496

@wibed

Description

@wibed

using esm module based project

{
  "start": "npm run clean && cross-env NODE_ENV=development NODE_OPTIONS=\"--loader=ts-node/esm --trace-warnings\" webpack serve --mode=development --config webpack.config.ts"
}

dotenv-webpack does not prevent the app from starting, any env variable ends up beeing undefined.
other plugins work as expected, thats why i dont assume my webpack.config.ts to be wrong

i load it as usual
as new Dotenv() entry in the plugin section:

...
import Dotenv from 'dotenv-webpack'
...
  plugins: [
    miniCSSPlugin,
    copyPlugin,
    htmlPlugin,
    forkCheckerPlugin,
    new Dotenv()
  ],
...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions