phoenixframework / esbuild

An installer for esbuild
MIT License
271 stars 38 forks source link

Can I pass `process.env.NODE_ENV` ? #45

Closed spapas closed 2 years ago

spapas commented 2 years ago

Hello, I'm trying to run the following:

mix esbuild  --no-runtime-config default  --minify --define:process.env.NODE_ENV='production' error.js

and getting the following error:

 > error: Missing "=": "process.env.NODE_ENV"

1 error
** (Mix) `mix esbuild default --minify --define:process.env.NODE_ENV 'production' error.js` exited with 1

It works fine if I skipe the --define option, i.e mix esbuild --no-runtime-config default --minify error.js. Also, calling esbuild directly with the --define works:

esbuild assets\error.js --define:process.env.NODE_ENV='development' --bundle --minify

Is it possible to pass the NODE_ENV somehow ?

If not how can I differentiate between prod and dev (or other environments I may compile my assets on) ?

TIA !

josevalim commented 2 years ago

That's a question for esbuild CLI. :) We simply forward the args. If it is possible via the CLI, then it should work, if it isn't, then there is nothing we can do.