From 9544c3e9a90c1c58476d3d87188f8ff39105294f Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:07:22 +0300 Subject: [PATCH] fix: use official `hash*` options for hashes (#1619) --- src/utils.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/utils.js b/src/utils.js index f76bf027..86866702 100644 --- a/src/utils.js +++ b/src/utils.js @@ -519,8 +519,6 @@ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) { ({ auto } = rawModulesOptions); } - // eslint-disable-next-line no-underscore-dangle - const { outputOptions } = loaderContext._compilation; const needNamedExport = exportType === "css-style-sheet" || exportType === "string"; const namedExport = @@ -539,10 +537,27 @@ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) { exportGlobals: false, localIdentName: "[hash:base64]", localIdentContext: loaderContext.rootContext, - localIdentHashSalt: outputOptions.hashSalt, - localIdentHashFunction: outputOptions.hashFunction, - localIdentHashDigest: outputOptions.hashDigest, - localIdentHashDigestLength: outputOptions.hashDigestLength, + // eslint-disable-next-line no-underscore-dangle + localIdentHashSalt: + loaderContext.hashSalt || + // TODO remove in the next major release + // eslint-disable-next-line no-underscore-dangle + loaderContext._compilation.outputOptions.hashSalt, + localIdentHashFunction: + loaderContext.hashFunction || + // TODO remove in the next major release + // eslint-disable-next-line no-underscore-dangle + loaderContext._compilation.outputOptions.hashFunction, + localIdentHashDigest: + loaderContext.hashDigest || + // TODO remove in the next major release + // eslint-disable-next-line no-underscore-dangle + loaderContext._compilation.outputOptions.hashDigest, + localIdentHashDigestLength: + loaderContext.hashDigestLength || + // TODO remove in the next major release + // eslint-disable-next-line no-underscore-dangle + loaderContext._compilation.outputOptions.hashDigestLength, // eslint-disable-next-line no-undefined localIdentRegExp: undefined, // eslint-disable-next-line no-undefined