davestewart / nuxt-content-assets

Enable locally-located assets in Nuxt Content
https://npmjs.com/package/nuxt-content-assets
108 stars 7 forks source link

Appending hash to imported files name #40

Open alexbidenko opened 1 year ago

alexbidenko commented 1 year ago

Background

When we use nuxt assets file import, in production mode nuxt appending file hash to files name. It is very useful because browser can understand when file has changed by filename - it is necessary for right caching for example.

But nuxt-content-assets plugin copy files only and do not append hash to its names. If I have used browser cache mechanism (for example by cache-control header) and then will have changed file (but not filename) - in browser I will have seen old image.

Proposal

It would be great if nuxt-content-assets added a hash of files to its filename (maybe with some enabled option in nuxt.config).

davestewart commented 1 year ago

Hey Alex,

In a pre-release version of the module I had a full assets path template system implemented:

...which I am considering bringing back.

Would this solve your problem?

alexbidenko commented 1 year ago

@davestewart , yes, it is looks like something great that I need exactly :)

Did I understand correctly that these changes can be expected soon in nuxt-content-assets?

davestewart commented 1 year ago

Hey Alex,

Short answer: probably.

Longer answer: I took it out as juggling paths was getting a bit complicated when I was iterating on the original concept, but I hope that it will still be viable to put it back in. I just need to find the time to reimplement, test and document.

Are you OK without the feature for now? What would be your ideal timescale?

alexbidenko commented 1 year ago

@davestewart , Without the hash feature I prefer to use paths to nuxt public folder and change filenames every time when I have changed files (for cache-control header optimization mechanism). It is because public folder as file storage more transparent for understanding by my colleagues.

But I like nuxt-content module and your nuxt-content-assets plugin is very perspective! I hope you can solve all your problems and your module will getting even better :) I'm willing to wait for updates to your plugin as long as necessary and use it in the future when the hash feature would be ready to use.