rollup-plugin-sass
rollup-plugin-sass copied to clipboard
Any hint on how to write hash in final file name?
Any hint on how to write hash in final file name?
Use the output: callback
option and generate a hash name from the callback parameters?
And how to "generate a hash name"?
Here's how I do it (based on rollup's own implementation):
import sha256 from 'hash.js/lib/hash/sha/256'
sass({
output: (style) => {
const hash = sha256().update(styles).digest('hex')
const fileName = `styles-${hash.substring(0, 8)}.css`
mkdirSync('path/to/output/dir', {recursive: true})
writeFileSync(`path/to/output/dir/${fileName}`, styles)
}
})
Moving to 'triaged' - For now the above solutions will suffice but we need to leverage rollup's existing lifecycle related config options (output.chunkFileNames
, etc.) to achieve the same thing. New ticket created: #122 .