feat(index): add checkCssChunk option and cssLinkHref function#256
feat(index): add checkCssChunk option and cssLinkHref function#256l5oo00 wants to merge 4 commits intowebpack:masterfrom l5oo00:master
checkCssChunk option and cssLinkHref function#256Conversation
give a chance to modify the css href by "mainTemplate.hooks.localVars" for another css resource manager
|
|
checkCssChunk && forceHookRuntime options
|
This change is for the runtime chunk, not for css files. I think it would be enough if the existing test cases passed, and I didn't see any existing tests for the runtime chunk. So need tests? |
|
@l5oo00 yes |
checkCssChunk && forceHookRuntime optionscheckCssChunk option
|
Remove // the `requireExtensions` hook in MainTemplate.js
this.hooks.requireExtensions.tap("MainTemplate", (source, chunk, hash) => {
const buf = [];
const chunkMaps = chunk.getChunkMaps();
// Check if there are non initial chunks which need to be imported using require-ensure
if (Object.keys(chunkMaps.hash).length) {
buf.push("// This file contains only the entry chunk.");
buf.push("// The chunk loading function for additional chunks");
buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);
buf.push(Template.indent("var promises = [];"));
buf.push(
Template.indent(
this.hooks.requireEnsure.call("", chunk, hash, "chunkId")
)
);
buf.push(Template.indent("return Promise.all(promises);"));
buf.push("};");
}
// ...
});And, @evilebottnawi added test for |
checkCssChunk optioncheckCssChunk option and cssLinkHref function
|
Any progress? I have found that if we use |
|
This PR break work |
|
So any proper way to work around such a situation, where I need the plugin not to check CSS chunks when Webpack bootstrap. |
|
@evilebottnawi Or any plan for doing the job of |
|
As we has already generate html to load css statically, we don't need the bootstrap css loading injection (which is after So we have workarounds like this config = {
// ...
plugins: [
// ...
Object.assign(new MiniCssExtractPlugin({filename : config.output.filename.replace(/\.js$/, '.css')}), {
// extracted css is preloaded, no bootstrap injection required
// simultaneously workaround the chunk loading problem, see https://github.com/webpack-contrib/mini-css-extract-plugin/pull/256
getCssChunkObject() { return {} },
})
// ...
]
}plugin itself should provider this option (preloaded css statically) in it's own config updated 2021-08-13 the hack not worked in 2.2.0 now |
|
the above hack is never worked now (version 2.2.0) since any other option? now we have to patch source to remove the whole |
|
the new workaround to remove config = {
// ...
plugins: [
new MiniCssExtractPlugin({/* ... */}), { // remove `__webpack_require__.f.miniCss`
apply(compiler) {
compiler.hooks.thisCompilation.tap('remove require.f.miniCss', compilation => {
compilation.hooks.afterRuntimeRequirements.tap('remove require.f.miniCss', () => {
[...compilation.modules].find(x => x.name === 'css loading').generate = () => null;
});
});
},
}
]
} |
|
give a chance to modify the css href by "mainTemplate.hooks.localVars" for another css resource manager.
This PR contains a:
Motivation / Use-Case
I just want to use this plugin to extract and load CSS files, but for CSS file dependency management, I need additional plugins to support.
So I need a chance to modify the css href, and do not check by
cssChunksvariable.Breaking Changes
no
Additional Info
no