From 23f5d43b4803a7551e2817c9cbdb13114b8a9d24 Mon Sep 17 00:00:00 2001 From: Borja Gonzalez Date: Fri, 9 Apr 2021 19:17:20 +0200 Subject: [PATCH] New css modules scoped names --- src/utils/build.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/build.js b/src/utils/build.js index 1b62d5f..114008f 100644 --- a/src/utils/build.js +++ b/src/utils/build.js @@ -13,11 +13,11 @@ const hash = (content) => content export const generateScopedName = () => { const hashes = {} - const getHash = (name, content) => { - if (!hashes[name]) hashes[name] = hash(content) - return hashes[name] - } - return (name, filename, css) => - `${getFileName(filename)}__${name}--${getHash(name, css)}` + return (name, file, css) => { + if (!hashes[file]) hashes[file] = {} + if (!hashes[file][name]) hashes[file][name] = hash(css) + + return `${getFileName(file)}__${name}--${hashes[file][name]}` + } }