assets-webpack-plugin
assets-webpack-plugin copied to clipboard
Non-SPA Setup: Single Runtime Exists In All Chunks
Describe the bug
In non-spa setup, every entry needs to be added into the page with only a single runtime using the webpack option runtimeChunk: "single"
.
This will generate runtime.js
for each entry. Like so
{
"runtime": {
"js": "/site/themes/raken-2.0/dist/runtime.1a9e8e42.js"
},
"main": {
"js": [
"/site/themes/raken-2.0/dist/runtime.1a9e8e42.js",
"/site/themes/raken-2.0/dist/vendors~main.9b76b42c.bundle.js",
"/site/themes/raken-2.0/dist/main.1653aa78.bundle.js"
]
},
"stylecss": {
"js": [
"/site/themes/raken-2.0/dist/runtime.1a9e8e42.js",
"/site/themes/raken-2.0/dist/style.2a6967b4.bundle.js"
],
"css": "/site/themes/raken-2.0/dist/style.3c41bfb5.css"
},
"utilcss": {
"js": [
"/site/themes/raken-2.0/dist/runtime.1a9e8e42.js",
"/site/themes/raken-2.0/dist/utils.f8096f3c.bundle.js"
],
"css": "/site/themes/raken-2.0/dist/utils.6ebc5c92.css"
}
}
Is there a way to filter runtime.js from all entries except for the runtime entry?
Expected Output
{
"runtime": {
"js": "/site/themes/raken-2.0/dist/runtime.1a9e8e42.js"
},
"main": {
"js": [
"/site/themes/raken-2.0/dist/vendors~main.9b76b42c.bundle.js",
"/site/themes/raken-2.0/dist/main.1653aa78.bundle.js"
]
},
"style": {
"js": "/site/themes/raken-2.0/dist/style.2a6967b4.bundle.js",
"css": "/site/themes/raken-2.0/dist/style.3c41bfb5.css"
},
"utils": {
"js": "/site/themes/raken-2.0/dist/utils.f8096f3c.bundle.js",
"css": "/site/themes/raken-2.0/dist/utils.6ebc5c92.css"
}
}
What Have I Tried?
I cannot use the setting where runtimeChunk: false|multiple
because that would generate multiple instances of HMR when loaded on the same page. This also make each entry contains a runtime which is also bad for performance.
I could see this being provided by the plugin. I'd be interested to hear some other feedback to see if I could make a more generic solution for this, rather than providing an option for just this specific case.
I don't have much time to work on this plugin lately, so I'm not sure when I'll get around to working on this unfortunately.