chainWebpack: config => { config.module.rules.delete('svg') // 删除默认svg配置 config.module .rule('svg-sprite-loader') .test(/.svg$/) .include .add(path.resolve(__dirname, './src/icons/')) .end() .use('svg-sprite-loader') .loader('svg-sprite-loader') .options({ symbolId: 'icon-[name]' }) },
参考文章:https://juejin.cn/post/6844903517564436493
https://www.zhangxinxu.com/wordpress/2014/07/introduce-svg-sprite-technology/