Earlier in webpack version 4 and node 14 version, runtimeChunkName was with pre-comipled chunk filepath, but now this is not working in webpack 5.
const beforeRenderPath = before-render/js/dist/BeforeRenderActivity-dyn
;
const runtimeChunkName =
env === 'development'
? ../${beforeRenderPath}
: ./plugins/${beforeRenderPath}
;
optimization: {
splitChunks: {
cacheGroups: {
antd: {
name: 'antd',
test: (module) => {
return (
/antd|rc-/.test(module.context) ||
/ant-design[\\/]icons/.test(module.context)
);
},
chunks: 'all',
priority: 2,
enforce: true
},
... some_more_vendors,
runtimeChunk: {
name: runtimeChunkName
}
How to serve runtimeChunk name with the help of filepath reference in webpack 5?
Error received is: Refused to execute script from because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled
Entry points looks like this:
This is served from plugin.json which is hash map.
{
"../../conf/login/js/dist/LoginView": "./plugins_on_premise/login/js/LoginView.tsx",
"../auth-provider/js/dist/AuthProvider": "./plugins_on_premise/auth-provider/js/AuthProvider.ts",
"../auth-provider/js/dist/RenewTokenActivity-dyn": "./plugins_on_premise/auth-provider/js/RenewTokenActivity-dyn.tsx",
"../_context-switch/js/dist/ContextSwitchActivity-dyn": "./plugins_on_premise/_context-switch/js/ContextSwitchActivity-dyn.tsx",
"../change-password/js/dist/ChangePasswordActivity-dyn": "./plugins_on_premise/change-password/js/ChangePasswordActivity-dyn.tsx",
"../before-render/js/dist/BeforeRenderActivity-dyn":
"./plugins/before-render/js/BeforeRenderActivity-dyn.tsx"
}
These are the versions in use:
"webpack": "5.88.2",
"webpack-bundle-analyzer": "4.9.0",
"webpack-chunk-rename-plugin": "1.0.3",
"webpack-cli": "5.1.4",
"webpack-dev-middleware": "6.1.1",
"webpack-dev-server": "4.15.1",
"webpack-hot-middleware": "2.25.4"
runtimeChunkName
in webpack-4 was pointing to a specific file: BeforeRenderActivity
as a dependency or pre-check earlier. But wepack 5 says, now need to use dependOn
with import syntax.
So what should be correct syntax for entries and now going forward runTimeChunkname should be kept or deleted or modified for optimization benefits that was carried from webpack 4.
Requesting a working example or steps to fix this.
How to fix this issue with multiple plugin entry that requires one precompiled entry in webpack 5?