-
-
Notifications
You must be signed in to change notification settings - Fork 7
Webpack Improvements #2
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
This comment was marked as abuse.
This comment was marked as abuse.
Now this does bring up another question, would a simple flag like "last: true" be enough? What happens if multiple plugins want to be applied "last"? Right now the order in which the configs are applied are based on the order in
|
This comment was marked as abuse.
This comment was marked as abuse.
Updated RFC with @NathanaelA I only implemented |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
About ordering and stuff. I'd really prefer a priority based approach. 100 by default and plugins can add This chain can then be passed along to Something like:
In the plugin's webpack.chain.js (referenced somewhere, either in hook or package.json):
|
Wouldn't it be better to say like |
I think it's easy to get carried away, and the first pass should just have the simpler The primary use-case for even specifying the My understanding is that all these plugins really need to do in the webpack config is adding new copy rules like With that in mind, let's see how this concrete example would work: // sqlite/nativescript.config.js
module.exports = webpack => {
// we probably want to add a helper like this, as it's common enough
// (the API/signature I need to think through, but had this on my mind for a while)
webpack.addCopyRule('**/*.sqlite')
webpack.chainWebpack((config) => {
// appears that webpack-chain doesn't have the nice syntax for externals yet (there's a pending issue)
// so we have to spread the existing ones along with our additions. Not pretty, but works.
config.externals([
...config.get('externals'),
'sqlite-commercial'
])
}, { order: 1 })
} // sqlite-commercial/nativescript.config.js
module.exports = webpack => {
webpack.chainWebpack((config) => {
// this plugin only has to remove itself from externals
// again, no pretty api from webpack-chain for this yet, but this looks reasonable
config.externals(
config.get('externals').filter(external => external !== 'sqlite-commercial')
)
}, { order: 2 })
} This should be fine even if there are multiple plugins with I'll experiment with this - and update the spec/RFC based on the feedback, but I wouldn't go further than this. If down the line we find legitimate use-cases where this is limiting, we can revisit and expose additional methods for altering the ordering without breaking changes. |
Updated RFC with the |
tl;dr A new and simpler webpack config file:
Rendered