@svg-load nav url( img/nav.svg ) { fill : #cfc ; path :nth-child ( two ) { fill : #ff0 ; } } .nav { background : svg-inline (nav); } .up { background : svg-load ( 'img/arrow-up.svg' , fill = #000 , stroke = #fff ); }
. nav { background : url ( "data:image/svg+xml;charset=utf-8,%3Csvg fill='%23cfc'%3E%3Cpath d='...'/%3E%3Cpath d='...' fill='%23ff0'/%3E%3Cpath d='...'/%3E%3C/svg%3E" ); } . up { background : url ( "data:image/svg+xml;charset=utf-8,%3Csvg fill='%23000' stroke='%23fff'%3E...%3C/svg%3E" ); }
.up { background : svg-load ( 'img/arrow-up.svg' , fill: #000 , stroke: #fff ); } .down { background : svg-load ( 'img/arrow-down.svg' , fill = #000 , stroke = #fff ); }
postcss ( [ require ( 'postcss-inline-svg' ) ( options ) ] )
function encode ( code ) {
return code
. replace ( / % / g , '%25' )
. replace ( / < / g , '%3C' )
. replace ( / > / g , '%3E' )
. replace ( / & / g , '%26' )
. replace ( / # / g , "%23" )
. replace ( / { / g , "%7B" )
. replace ( / } / g , "%7D" ) ;
}
< svg > < path fill = " #ff0000 " d = " ... " /> </ svg >
< svg fill = " #000 " > < path fill = " #ff0000 " d = " ... " /> </ svg >
There is a plugin. :)
postcss ( [
require ( 'postcss-inline-svg' ) ,
require ( 'postcss-svgo' )
] )
postcss ( [
require ( 'postcss-inline-svg' ) ,
require ( 'cssnano' )
] )