nystudio107 / craft-plugin-vite

Plugin Vite is the conduit between Craft CMS plugins and Vite, with manifest.json & HMR support
MIT License
12 stars 11 forks source link

Cache busting with [hash] as queryparameter instead of filename #20

Closed Tim-Wils closed 9 months ago

Tim-Wils commented 11 months ago

Hi Andrew! We use the craft.vite.script() function to create tags automagically, but we now walk into something of a feature request. We're building the assets without hash, but we want to make use of the hash that's in manifest as a cache-busting mechanism.

I know I could place all the script/links tags manually in the layout and paste ?v={{ craft.vite.getCssHash("src/js/app.ts") }} behind every url. But it would be awesome to have if we can do this as an extra parameter in the .script() function like below and keep the awesomeness that .script() is generating:

{{ craft.vite.script("src/js/app.ts", true,{},{},{
queryparams: 'v='~craft.vite.getCssHash("src/js/app.ts")
}) }}

What do you think of this?

Cheers!

khalwat commented 10 months ago

Yeah I'd recommend building the assets with a hash -- is there a specific reason you're not doing that?