icon icon indicating copy to clipboard operation
icon copied to clipboard

how to disable svg caching

Open blasdfaa opened this issue 1 year ago • 6 comments

How can I disable icon caching? I'm doing svg animation and I need hmr when changing an svg file.

https://stackblitz.com/edit/nuxt-icon-playground-mjfbfn?file=assets%2Ficons%2Fnuxt-icon.svg Try changing the fill attribute of the svg file and save it

blasdfaa avatar May 11 '24 20:05 blasdfaa

Why not creating a .vue component and use the SVG inside for such a specific use case?

atinux avatar May 22 '24 12:05 atinux

Also need this. Cache is super annoying during development.

gigor avatar Dec 12 '24 07:12 gigor

This wasn't about caching, I think; it's more like it wasn't picking up the updates for custom collections. https://github.com/nuxt/icon/pull/282 should already fixed this.

antfu avatar Dec 18 '24 08:12 antfu

@antfu thanks for looking at it. Still have this behavior with local svgs on 1.10.2. Refreshing page does not help, neither does restarting nuxt, the only thing that makes svg change to be shown is rm -rf .nuxt/cache/nuxt/icon

The config looks like this:

icon: {
        provider: 'server',
        mode: 'svg',
        customCollections: [
            {
                prefix: 'local',
                dir: './assets/icons',
                normalizeIconName: false
            }
        ]
    }

gigor avatar Dec 18 '24 10:12 gigor

c6956675c61fe669bfa1311c6db56bf036fc603b should fix it. Tho it's a bit tricky to support real HMR as the rendered icons do not have a direct relationship with the source, but in 1.10.3 at least it make client refresh work without restarting the server.

antfu avatar Dec 20 '24 08:12 antfu

Still does not work. The json file in .nuxt/cache/nuxt/icon does not get updated neither on svg file change nor on server restart.

Here is stackbiz reproduction https://stackblitz.com/edit/nuxt-icon-3trsfvly?file=assets%2Ficons%2Fnuxt-icon.svg

There is also a new error on nuxt dev: ERROR [uncaughtException] t._onTimeout is not a function

gigor avatar Dec 20 '24 10:12 gigor