From 4c11c5dfde9d87d71dce9cf51864648f8e42b912 Mon Sep 17 00:00:00 2001 From: Sibiraj Date: Mon, 1 Oct 2018 16:56:33 +0530 Subject: [PATCH] fix: rename `contenthash` to `templatehash` BREAKING: `contenthash` in now `templatehash`. Since webpack 4.3 `contenthash` is used by webpack. to avoid conflicts, it is renamed to `templatehash` --- index.js | 4 ++-- spec/basic.spec.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 878f950e..d96988bc 100644 --- a/index.js +++ b/index.js @@ -279,10 +279,10 @@ class HtmlWebpackPlugin { return self.options.showErrors ? prettyError(err, compiler.context).toHtml() : 'ERROR'; }) .then(html => { - // Allow to use [contenthash] as placeholder for the html-webpack-plugin name + // Allow to use [templatehash] as placeholder for the html-webpack-plugin name // See also https://survivejs.com/webpack/optimizing/adding-hashes-to-filenames/ // From https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/8de6558e33487e7606e7cd7cb2adc2cccafef272/src/index.js#L212-L214 - const finalOutputName = childCompilationOutputName.replace(/\[(?:(\w+):)?contenthash(?::([a-z]+\d*))?(?::(\d+))?\]/ig, (_, hashType, digestType, maxLength) => { + const finalOutputName = childCompilationOutputName.replace(/\[(?:(\w+):)?templatehash(?::([a-z]+\d*))?(?::(\d+))?\]/ig, (_, hashType, digestType, maxLength) => { return loaderUtils.getHashDigest(Buffer.from(html, 'utf8'), hashType, digestType, parseInt(maxLength, 10)); }); // Add the evaluated html code to the webpack assets diff --git a/spec/basic.spec.js b/spec/basic.spec.js index 4dc1a8f9..17df8a6b 100644 --- a/spec/basic.spec.js +++ b/spec/basic.spec.js @@ -626,7 +626,7 @@ describe('HtmlWebpackPlugin', () => { }, ['