Closed ciampam9 closed 6 years ago
@ciampam9 Apologies for late reply. Good question - basically I wanted to remove it in this PR #1359 but totally forgot in the end. If you check out that PR I have explained the reasons for only having development and production for NODE_ENV
.
In earlier versions of webpacker we have used Rails env as fallback env, which isn't ideal because both NODE_ENV and RAILS_ENV has different meaning for different environments.
For example: setting NODE_ENV=production means the webpacker will compile assets in production mode however at same time RAILS_ENV can be staging. Webpack and node libraries only understands development and production environments. However, it's normal to have many custom RAILS_ENV.
For your use case you could do, since now RAILS_ENV
is used for loading configurations:
#Â NODE_ENV is development by default
RAILS_ENV=test ./bin/webpack
or you could use
RAILS_ENV=test bundle exec rails webpacker:compile
RAILS_ENV=test bundle exec rails assets:precompile
@gauravtiwari Not sure if this is the same issue but even when I set RAILS_ENV=test
I get output files in my packs
and not packs-test
as configured in my webpacker.yml
, so it seems to be using NODE_ENV
which is overridden to production
when selecting the config
@aceofspades What version of webpacker are you using?
@gauravtiwari Found my issue, looks like I wasn't in sync with the gem & node package. Interesting, would be nice if this condition were detected, it caused quite a bit of debug time
👋 Hey all!
Is there a reason why we're not allowing webpack to run
environment/test.js
? It seems as though when runningNODE_ENV=test ./bin/webpack
, thenodeEnv
inpackage/env.js
is being overridden toproduction
.Currently, if the node env isn't a part of the whitelist (package/env.js):
it defaults to
production
(package/env.js):Would it be possible to whitelist test as well? If the package has a specific test environment we should be allowed to use it by setting the node env, imo.
I realize this is outlined in the docs but why would we still have a
package/environments/test.js
file if you cannot run it?