-
-
Notifications
You must be signed in to change notification settings - Fork 496
Set NODE_ENV var when running Encore scripts #747
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
@Lyrkan @weaverryan what do you think about this proposal after the latest changes that you suggested? Should we add this or close it as "won't fix"? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about this proposal after the latest changes that you suggested?
Let's go with this.
It may not always work depending on how the process that reads the other config file is called/implemented but it should be OK for most use cases.
@@ -1,5 +1,9 @@ | |||
var Encore = require('@symfony/webpack-encore'); | |||
|
|||
// Optional: sync the NODE_ENV value with the current Webpack Encore environment | |||
// It’s useful if you need to read the Webpack Encore environment from some other config file | |||
// process.env.NODE_ENV = Encore.isProduction() ? 'production' : 'development'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be moved after the Manually configure the runtime environment
case
I love this idea :) |
Please rebase so that the new checks can run. |
In a project I needed to enable PurgeCSS only when in production. This is done in postcss.config.js and there's no way to know if Encore is running in production or not. I asked on Slack and @Lyrkan proposed this solution to me. It worked for me nicely!
As I think this could be useful to others, I propose this change in case it makes sense to make it in general for all projects.