vshepel / vite-svg-sprite-wrapper

Creating one sprite file on the fly
27 stars 5 forks source link

emptyOutDir immediately removes the generated sprite #12

Closed kinglozzer closed 5 months ago

kinglozzer commented 5 months ago

Hi,

By default build.emptyOutDir is true, but this removes the sprite as soon as it’s generated if the outputdir is within build.outDir:

import { defineConfig } from 'vite';
import ViteSvgSpriteWrapper from 'vite-svg-sprite-wrapper';

export default defineConfig({
  plugins: [
    ViteSvgSpriteWrapper({
      icons: 'src/images/icons/*.svg',
      outputDir: './dist',
    }),
  ],
  build: {
    assetsDir: '',
    emptyOutDir: true,
    copyPublicDir: false,
    manifest: true,
    outDir: './dist',
    rollupOptions: {
      input: [
        'src/js/app.js'
      ]
    },
  },
});
kinglozzer commented 5 months ago

Using buildEnd stops the sprite being removed, but I’m not sure if this will have other side-effects

vshepel commented 5 months ago

@kinglozzer I'm working on it, but the main problem is that I'm not using emitFile and transform when building, we're already having problems with that, so you can follow the progress here - https://github.com/vshepel/vite-svg-sprite-wrapper/issues/10