vbenjs / vite-plugin-svg-icons

Vite Plugin for fast creating SVG sprites.
MIT License
818 stars 111 forks source link

How to remove fill attrs ? #70

Open liulib opened 2 years ago

liulib commented 2 years ago

In vue2 and webpack, i use svgo-loader to remove fill like this

module.exports = {
    chainWebpack: config => {
        const dir = path.resolve(__dirname, 'src/assets/icons');
        config.module
            .use('svgo-loader')
            .loader('svgo-loader')
            .tap(options => ({
                ...options,
                plugins: [
                    {
                        name: 'removeAttrs',
                        params: {
                            attrs: 'fill'
                        }
                    },
                    {
                        name: 'removeTitle'
                    }
                ]
            }))
            .end();
    }
};

thanks for helping

ElenaKiseljova commented 2 years ago

You must add svgoOptions property in vite.config.js

createSvgIconsPlugin({ // ---- svgoOptions: { plugins: [ { name: 'removeAttrs', params: { attrs: ['class', 'data-name', 'fill', 'stroke'], }, }, ], }, // ---- }),