Skip to content

Commit b6895cb

Browse files
committed
feat: use webpack 5 api to add assets
1 parent 56e633f commit b6895cb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const fs = require('fs');
1515
const _ = require('lodash');
1616
const path = require('path');
1717
const loaderUtils = require('loader-utils');
18+
const webpack = require('webpack');
1819
const { CachedChildCompilation } = require('./lib/cached-child-compiler');
1920

2021
const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } = require('./lib/html-tags');
@@ -329,10 +330,7 @@ function hookIntoCompiler (compiler, options, plugin) {
329330
return loaderUtils.getHashDigest(Buffer.from(html, 'utf8'), hashType, digestType, parseInt(maxLength, 10));
330331
});
331332
// Add the evaluated html code to the webpack assets
332-
compilation.assets[finalOutputName] = {
333-
source: () => html,
334-
size: () => html.length
335-
};
333+
compilation.emitAsset(finalOutputName, new webpack.sources.RawSource(html, false));
336334
return finalOutputName;
337335
})
338336
.then((finalOutputName) => getHtmlWebpackPluginHooks(compilation).afterEmit.promise({

0 commit comments

Comments
 (0)