-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
feat: add Encore.when() #963
Conversation
@@ -1596,6 +1596,29 @@ class Encore { | |||
return webpackConfig.isDevServer(); | |||
} | |||
|
|||
/** | |||
* Use to conditionally configure or enable features only in when the first parameter results to "true". |
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.
* Use to conditionally configure or enable features only in when the first parameter results to "true". | |
* Use to conditionally configure or enable features only when the first parameter results to "true". |
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.
Updated at sha: d074101
* // passing a callback | ||
* .when((Encore) => Encore.isProduction(), (Encore) => Encore.enableVersioning()) | ||
* // passing a boolean | ||
* .when(process.argv.includes('--analyze'), (Encore) => Encore.addPlugin(new BundleAnalyzerPlugin())) |
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.
Cool examples!
This is very cool - thank you @Kocal! |
Replace #900 by adding a more generic and flexible API than
Encore.isDev()
/Encore.isProd()
, see #900 (comment).Encore.when()
takes two parameters:condition
: can be a callback (where the current instance of Encore is passed as first parameter) or a boolean. If this results totrue
, the parametercallback
is calledcallback
: executed when parametercondition
results totrue
, it takes the current instance of Encore as first parameterWDYT? Thanks!