File tree Expand file tree Collapse file tree 4 files changed +26
-10
lines changed
Expand file tree Collapse file tree 4 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -62,4 +62,8 @@ describe('Vite SVG Loader', () => {
6262 expect ( $img [ 0 ] . width ) . to . equal ( 355 )
6363 } )
6464 } )
65+
66+ it ( "it send path to svgo" , ( ) => {
67+ cy . get ( "#component svg .test_svg__rectangle" ) . should ( "exist" ) ;
68+ } ) ;
6569} )
Original file line number Diff line number Diff line change @@ -12,7 +12,18 @@ export default defineConfig(({ mode }) => {
1212 const DEFAULT_IMPORT = env . VITE_SVG_DEFAULT_IMPORT || env . npm_config_svg_default_import
1313
1414 return {
15- plugins : [ vue ( ) , viteSvgLoader ( { defaultImport : DEFAULT_IMPORT } ) ] ,
15+ plugins : [
16+ vue ( ) ,
17+ viteSvgLoader ( {
18+ defaultImport : DEFAULT_IMPORT ,
19+ svgoConfig : {
20+ plugins : [
21+ 'preset-default' ,
22+ { name : 'prefixIds' } ,
23+ ] ,
24+ }
25+ } )
26+ ] ,
1627
1728 resolve : {
1829 alias : {
Original file line number Diff line number Diff line change 11const fs = require ( 'fs' ) . promises
22const { compileTemplate } = require ( '@vue/compiler-sfc' )
3- const { optimize : optimizeSvg } = require ( 'svgo' )
3+ const { optimize } = require ( 'svgo' )
44
55module . exports = function svgLoader ( options = { } ) {
66 const { svgoConfig, svgo, defaultImport } = options
@@ -38,7 +38,10 @@ module.exports = function svgLoader (options = {}) {
3838 }
3939
4040 if ( svgo !== false && query !== 'skipsvgo' ) {
41- svg = optimizeSvg ( svg , svgoConfig ) . data
41+ svg = optimize ( svg , {
42+ ...svgoConfig ,
43+ path
44+ } ) . data
4245 }
4346
4447 const { code } = compileTemplate ( {
You can’t perform that action at this time.
0 commit comments