Closed m5r closed 10 months ago
Agree we should avoid this and not touch NODE_ENV
but it will have to come in a major release as it could be a breaking change for other users 👍
Noticed something else when working through the issue though, currently the framework forces you to create a config.{env}.js
file if you specify the env
when using it programmatically:
This shouldn't be the case and it should simply fallback to the 'local' config.js
or config.local.js
that it computes before that. And even if that one is missing, worst case it would fallback to an empty object, as pretty much everything in Maizzle can (and should) work with some defaults.
This would also be a breaking change so I think we can group them together for Maizzle 5.
Not a big fan of the long config file names tbh, but maybe we could do maizzle.js
and maizzle.production.js
, not sure yet...
I can see why it could make sense to need a config file when using the CLI if the defaults are not enough but it shouldn't require a config file when used programmatically if the config is already passed as a parameter.
Yeah, it makes sense to group these two breaking changes together.
I'm using maizzle to programmatically render emails and I don't use any maizzle environment as my config is inlined in my code. So maizzle believes I'm using the
local
environment and it overridesprocess.env.NODE_ENV
with an arbitrary value in https://github.com/maizzle/framework/blob/master/src/generators/output/to-string.js#L10 and in https://github.com/maizzle/framework/blob/master/src/generators/output/to-disk.js#L15This is causing my code to behave unexpectedly because it relies on
process.env.NODE_ENV
to beproduction
.The quick fix I came up with was setting
options.maizzle.env
toprocess.env.NODE_ENV
and creating two empty config filesconfig.production.js
&config.development.js
but I would prefer for maizzle to not override my environment variables, especially notNODE_ENV
.Side note, I believe it would make more sense to include
maizzle
in the config files name (i.e. maizzle.config.production.js`), the current name is too generic.