From 569821c95dcaa5b1488586751a21c671fe7ae69c Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Sun, 26 May 2019 21:33:07 +0430 Subject: [PATCH] fix(styles): inline all styles on optimization phase By definition, a defs sprite is not usable as a CSS sprite fix #19 --- lib/svg.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/svg.js b/lib/svg.js index 3e70d046..61516d39 100644 --- a/lib/svg.js +++ b/lib/svg.js @@ -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 @@ -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 ] })