Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RAILS_ENV in runner webpack config. #1830

Closed
wants to merge 1 commit into from
Closed

Use RAILS_ENV in runner webpack config. #1830

wants to merge 1 commit into from

Conversation

phlegx
Copy link

@phlegx phlegx commented Dec 11, 2018

This pull request allow to have webpack configs for other environments then development, test and production. For example using environment staging. With this changes an own config/webpack/staging.js is possible (for example with specific process.env variables or webpack configs that differs from production).

Task webpacker:compile has environment production hardcoded. For environments like staging this is not a problem, but for other environments not using a production node environment it is. This could also be changed, respecting the NODE_ENV. Here an example not included in this pull request.

See #1696 #1558 #1274

This allows to have webpack configs for other environments then development, test and production. For example using environment staging.js.
@gauravtiwari
Copy link
Member

Thanks for the PR but I am not sure if there is ever a need of other environments in the context of NODE_ENV. You can use RAILS_ENV to set a custom environment, which will tell webpack to load settings from the relevant section of the webpacker.yml.

As far as webpack is concerned, it will compile, the packs in either production or development mode (with different loaders or plugins useful for that environment). You can supply env variables to change settings during builds. For example, a different API URL for staging vs production.

There is no need for another config file if you are just changing env variables.

@phlegx
Copy link
Author

phlegx commented Dec 12, 2018

@gauravtiwari you write: You can supply env variables to change settings during builds. For example, a different API URL for staging vs production.

Can you show me please an example how to do that?

@gauravtiwari
Copy link
Member

@phlegx Sure, here is some documentation: https://github.com/rails/webpacker/blob/master/docs/env.md

But basically, you can pass env variable like so:

API_URL=foo bundle exec rails s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants