-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
merging loaders and making plugins unique? #176
Comments
I've found it's easier to solve these cases through composition as that avoids the problem altogether and keeps Can you share your current configuration so I can propose how you could solve it this way? |
I have it on two levels, in my cms config and prod config.
PROD:
|
Ok, I see now. I think this is how I would solve it. ...
// Add parameters as you prefer
function generateHtml({ templateParameters }) {
return {
plugins: [
new HtmlWebpackPlugin({
template: 'src/cms.ejs',
inject: true,
filename: 'cms.html',
templateParameters
})
]
};
}
// ... then compose for both separately along this
module.exports = merge({ ... }, { ... }, generateHtml({ templateParameters: { cms: 'realurls' }})) I think pushing it to a separate utility is a good way to solve it. If you use TypeScript, you can also document your API this way. I've written a lot about the approach in my book (free) at https://survivejs.com/webpack/. |
Note that I edited my comment a bit. It should have close to correct syntax now. 👍 |
Okay, I had to combine this with the switch variation from the examples, but this part is now fully functional. Do you have an advice for loader order? |
I've used a similar approach for loaders. I.e. I wrap them into smaller functions to compose and then attach them per target. Some will fit common configuration directly and doing this avoids the need for Can you paste your current loaders so I can propose a possible composition? |
It's rather complex and I'd have to do some redactions haha. Instead, I have sorted it based on your idea. :) It's modular and only uses Thanks for your help. |
OS: Win10
Node: v14.15.4
Hi there,
following the examples I have been able to merge my loaders by using
mergeWithRules
and I have also been able to test outmergeWithCustomize
andcustomizeArray
successfully.However, I need to combine the two steps, as the configs I'm merging have different options for some of the plugin options.
Is this possible?
Looking at the source, I can see that
mergeWithRules
returnsmergeWithCustomize
but unable to figure out how to combine the two.The text was updated successfully, but these errors were encountered: