I am new to webpack and worked out almost all build sections, but now the problem is that I want to pass the environment variables from a .env file to webpack config, so tha
I did get inspiration from the accepted answer, but it doesn't work for me. Maybe the API of dotenv has changed.
The following works for me
import dotenv from 'dotenv'
import { DefinePlugin } from 'webpack'
...
plugins: [
new DefinePlugin({
'process.env': JSON.stringify(dotenv.config().parsed)
})
]
...