jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

Rich svg files not being optimized #32

Closed eloytoro closed 8 years ago

eloytoro commented 8 years ago

Svgs that have comments or unknown tags, we should optimize them

jhamlet commented 8 years ago

Please use svgo-loader to optimize your SVGs before they get to svg-react-loader. You can use it as a preloader, or add it to the loader chain for your SVGs.

ex.:

// file: webpack.config.js
module.exports = {
    //...
    module: {
        preLoaders: [
            { test: /\.svg$/, loader: 'svgo?useConfig=svgoConfig' }
        ],
        // or
        loaders: [
            {
                test: /\.svg/,
                loader: 'babel!svg-react!svgo',
                query: {
                    useConfig: 'svgoConfig',
                    presets: ['es2015', 'react']
                }
            }
        ]
        //...
    }
}

Thanks,

;-j