mrsteele / dotenv-webpack

A secure webpack plugin that supports dotenv and other environment variables and only exposes what you choose and use.
MIT License
1.3k stars 74 forks source link

How to load var from package.json #464

Closed jasan-s closed 3 years ago

jasan-s commented 3 years ago

i.e "start": "APP_ENV=dev webpack serve",

mrsteele commented 3 years ago

You need a node process defined first, perhaps you could create a script that loads your env first?

// init.js
require('dotenv').config()
// package.json
{
  ...
  "scripts": {
    "start": "node init && webpack server"
  }
}

Closing, but feel free to mention if that isn't correct.