Skip to content

Commit

Permalink
New css modules scoped names
Browse files Browse the repository at this point in the history
  • Loading branch information
bgonp committed Apr 9, 2021
1 parent ad15d8a commit 23f5d43
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/utils/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]}`
}
}

0 comments on commit 23f5d43

Please sign in to comment.