vbenjs / vite-plugin-svg-icons

Vite Plugin for fast creating SVG sprites.
MIT License
801 stars 109 forks source link

Is it possible to create multiple sets of SVG sprites with different options? #96

Open nat-davydova opened 11 months ago

nat-davydova commented 11 months ago

I want to get 2 sets of sprites with different SVGO options.

If I do like this, only the first configuration is applied. What should I do to make both work?

import path from "path";

import { createSvgIconsPlugin } from "vite-plugin-svg-icons";

export default () => {
  return {
    plugins: [
      createSvgIconsPlugin({
        // Specify the icon folder to be cached
        iconDirs: [path.resolve(process.cwd(), "src/assets/icons/colored")],
        // Specify symbolId format
        symbolId: "icon-colored-[name]",

        /**
         * custom dom id
         * @default: __svg__icons__dom__
         */
        customDomId: "__svg__icons__colored__dom__",
        svgoOptions: {
          plugins: [
            {
              name: "removeAttrs",
              params: { attrs: ["width", "height"] },
            },
          ],
        },
      }),

      createSvgIconsPlugin({
        // Specify the icon folder to be cached
        iconDirs: [path.resolve(process.cwd(), "src/assets/icons/solid")],
        // Specify symbolId format
        symbolId: "icon-solid-[name]",

        /**
         * custom dom id
         * @default: __svg__icons__dom__
         */
        customDomId: "__svg__icons__solid__dom__",
        svgoOptions: {
          plugins: [
            {
              name: "removeAttrs",
              params: { attrs: ["width", "height", "fill", "stroke"] },
            },
          ],
        },
      }),
    ],
  };
};