diff --git a/package.json b/package.json index 7723865..74cc075 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack-svg-sprite-generator", - "version": "1.0.16", + "version": "1.0.17", "description": "", "main": "plugin.js", "types": "ts/index.d.ts", diff --git a/plugin/generator.ts b/plugin/generator.ts index e81b012..ad9d395 100644 --- a/plugin/generator.ts +++ b/plugin/generator.ts @@ -93,7 +93,9 @@ export async function generateSpriteCss(options: SpriteCssOptions, classPrefix: let result = ""; result += `${options.selector}{`; result += `display:inline-block;`; - result += `background:url("${publicUrl}") no-repeat;`; + /* doing a relative path here as well since WebPack may messes around here since the public path may start with / and if it's a file path / means the root... */ + result += `background-image:url(".${publicUrl}"),url("${publicUrl}");`; + result += `background-repeat:no-repeat;`; result += `background-size:${sprite.width * scaleX}${options.unit} ${sprite.height * scaleY}${options.unit};`; result += `height:${defaultHeight * scaleY}${options.unit};`; result += `width:${defaultWidth * scaleX}${options.unit}`;