-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Current behaviour π£
In v4.0.0. removed a hook called htmlWebpackPluginAlterChunks
but without any reasoning or documented replacement (342867e).
I've picked up an old project and I'm rying to use this hook in a plugin pulled from a (now archived) Shopify Slate theme tool. However without any documented upgrade path I've hit a dead end.
I understand that its been missing for years now, but if theres any documentaiton or thoughts on how it can replaced, I'd be greatly appreciative.
Expected behaviour βοΈ
To have a documented replacement for htmlWebpackPluginAlterChunks
Reproduction Example πΎ
constructor(options) {
this.options = options;
this.files = [];
}
apply(compiler) {
compiler.hooks.compilation.tap(
'htmlWebpackIncludeChunksPlugin',
this.onCompilation.bind(this),
);
}
onCompilation(compilation) {
this.compilation = compilation;
compilation.hooks.htmlWebpackPluginAlterChunks.tap(
'htmlWebpackIncludeChunksPlugin',
this.onAlterChunks.bind(this),
);
compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration.tap(
'htmlWebpackIncludeChunksPlugin',
this.onBeforeHtmlGeneration.bind(this),
);
}
onAlterChunks(chunks) {
this.chunks = chunks;
}
onBeforeHtmlGeneration(htmlPluginData) {
const assets = htmlPluginData.assets;
const publicPath = assets.publicPath;
this.chunks.forEach((chunk) => {
const name = chunk.names[0];
const chunkFiles = []
.concat(chunk.files)
.map((chunkFile) => publicPath + chunkFile);
const css = chunkFiles
.filter((chunkFile) => /.(css|scss)\.liquid($|\?)/.test(chunkFile))
.map((chunkFile) => chunkFile.replace(/(\.css)?\.liquid$/, '.css'));
assets.chunks[name].css = css;
assets.css = assets.css.concat(css);
});
}
}
module.exports = HtmlWebpackIncludeLiquidStylesPlugin;
Environment π₯
Node.js v16.15.0
darwin 21.5.0
8.5.5
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ¬ [email protected]
β β βββ [email protected] deduped
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ [email protected] deduped
βββ¬ [email protected]
β βββ¬ @webpack-cli/[email protected]
β β βββ [email protected] deduped
β βββ [email protected] deduped
βββ [email protected]
βββ [email protected]
roryabraham
Metadata
Metadata
Assignees
Labels
No labels