Skip to content

Commit

Permalink
fix(styles): inline all styles on optimization phase
Browse files Browse the repository at this point in the history
By definition, a defs sprite is not usable as a CSS sprite
fix #19
  • Loading branch information
farnabaz committed May 26, 2019
1 parent cf8e0fa commit 569821c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cleanupIDs from 'svgo/plugins/cleanupIDs'
import removeAttrs from 'svgo/plugins/removeAttrs'
import removeDimensions from 'svgo/plugins/removeDimensions'
import removeViewBox from 'svgo/plugins/removeViewBox'
import inlineStyles from 'svgo/plugins/inlineStyles'

// Enable removeAttrs plugin
// Remove id attribute to prevent conflict with our id
Expand All @@ -15,12 +16,18 @@ removeAttrs.params.attrs = 'svg:id'
removeViewBox.active = false
removeDimensions.active = true

// Make all styles inline
// By definition, a defs sprite is not usable as a CSS sprite
inlineStyles.active = true
inlineStyles.params.onlyMatchedOnce = false

const svgOptimizer = new Svgo({
pluging: [
removeDimensions,
cleanupIDs,
removeAttrs,
removeViewBox
removeViewBox,
inlineStyles
]
})

Expand Down

0 comments on commit 569821c

Please sign in to comment.