Skip to content

Documentation on SVG variant needs Vite integration #33

Open

Description

@ratijas

Documentation on SVG variant of icons currently only mentions how to integrate with WebPack.

https://github.com/marella/material-design-icons/tree/main/svg

As far as I'm aware, the frontend world is moving towards Vite ecosystem.

Thus, the documentation needs an update to reference SVG+Vite+<Framework> integrations such as vite-svg-loader (confusingly, despite the name it is specifically for Vue.js) and vite-plugin-svgr (for React).

Activity

  1. ratijas commented on Dec 11, 2025

    @ratijas
    Author

    Actually there is already a PR which describes a workaround for vite-svg-loader: jpkleemans/vite-svg-loader#120 and I think it should be included here too.

    By default, SVGO does not preserve the viewBox attribute for optimization reasons. This can cause issues when you need to resize your SVG with CSS. You can pass options to svgLoader() to disable the removal of the viewBox attribute.

    import vue from '@vitejs/plugin-vue'
    import { defineConfig } from 'vite'
    import svgLoader from 'vite-svg-loader'
    
    // https://vite.dev/config/
    export default defineConfig({
      plugins: [
        vue(),
        svgLoader({
          svgoConfig: {
            multipass: true,
            plugins: [
              {
                name: "preset-default",
                params: {
                  overrides: {
                    // @see https://github.com/svg/svgo/issues/1128
                    removeViewBox: false,
                  },
                },
              },
            ],
          },
        }),
      ],
    })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions