You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the different configuration callbacks we expose are expecting to alter the options object directly.
But this makes it much harder to use libraries exposing a function processing options and returning new ones
#294 shows such a use case. #294 (comment) is showing the current code needed to handle it, while #294 (comment) shows how this could look like with this proposal.
The idea would be simple: inspect the return value of the callback when calling it:
if it is an object, use it as the new options object
if it is undefined (nothing was returned), keep using the existing options object (which may have been altered inside the callback, as done today).
The text was updated successfully, but these errors were encountered:
…kan)
This PR was squashed before being merged into the master branch (closes#300).
Discussion
----------
Allow to replace options in configuration callbacks
This PR closes#298 by using the return value of callback functions (for loaders/plugins) as options if it is an object.
For instance:
```js
Encore.configureUglifyJsPlugin((options) => {
return {
...options,
beautify: true
};
});
```
Commits
-------
3dfc787 Revert a forgotten 'let' to a 'const'
ef992c1 Replace duplicated 'options callback' logic by an utility method
ecb623c Allow to replace options in configuration callbacks
Currently, the different configuration callbacks we expose are expecting to alter the options object directly.
But this makes it much harder to use libraries exposing a function processing options and returning new ones
#294 shows such a use case. #294 (comment) is showing the current code needed to handle it, while #294 (comment) shows how this could look like with this proposal.
The idea would be simple: inspect the return value of the callback when calling it:
The text was updated successfully, but these errors were encountered: