Is there a way to hash the asset file names? #917
Unanswered
bravecrayon
asked this question in
Q&A
Replies: 1 comment
-
There isn't a way to hash asset file names yet in Maizzle. And the URL Parameters transformer currently only works on One option would be to write a custom PostHTML plugin that adds a // config.js
module.exports = {
build: {
posthtml: {
plugins: [
(() => tree => {
const process = node => {
if (node.tag === 'img' && node.attrs?.src) {
const randomNumber = Math.floor(Math.random() * 10 ** 16).toString().padStart(16, '0')
node.attrs.src = node.attrs.src + `?v=${randomNumber}`
}
return node
}
return tree.walk(process)
})()
],
},
// ...
},
} Of course that would only work on |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Replacing an image on the CDN occasionally will be cached at the local level. Is there a recommended way, or can someone point me in a direction, of adding a hash to the asset file names during a build (like
foo-0dc167866d1f.jpeg
) while keeping all of the references in the rendered html correct?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions