Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any hint on how to write hash in final file name? #65

Open
frederikhors opened this issue Jun 1, 2019 · 4 comments
Open

Any hint on how to write hash in final file name? #65

frederikhors opened this issue Jun 1, 2019 · 4 comments
Labels
discussion triaged When an issue has been groomed, reproduced, and/or, validated.

Comments

@frederikhors
Copy link

Any hint on how to write hash in final file name?

@differui
Copy link
Collaborator

differui commented Jun 2, 2019

Use the output: callback option and generate a hash name from the callback parameters?

@frederikhors
Copy link
Author

And how to "generate a hash name"?

@SKalt
Copy link

SKalt commented Oct 6, 2019

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)
  }
})

@elycruz
Copy link
Owner

elycruz commented Oct 7, 2023

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 .

@elycruz elycruz added the triaged When an issue has been groomed, reproduced, and/or, validated. label Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion triaged When an issue has been groomed, reproduced, and/or, validated.
Projects
None yet
Development

No branches or pull requests

4 participants