JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.02k stars 272 forks source link

spritePlaceholder function might expose server file structure in multisite environment #387

Open usqr opened 4 years ago

usqr commented 4 years ago

What is the current behavior? spritePlaceholder function exposes server file structure in a multisite environment SVG file content:

export default {
      id: "sprite-01-usage",
      viewBox: "0 0 34.616 34.616",
      url: "/" + "C:\\wamp64\\[...]\\web\\img\\svg-sprites\\sprite-01.svg",
      toString: function () {
        return this.url;
      }
    }

What is the expected behavior? Ability to turn off the full URL info

export default {
      id: "sprite-01-usage",
      viewBox: "0 0 34.616 34.616",
      url: "/",
      toString: function () {
        return this.url;
      }
    }

If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code.

Webpack config:

[...]
  .addLoader({
      test: /svg-sprites(\/|\\).*\.svg$/, // your icons directory
      loader: 'svg-sprite-loader',
      options: {
        extract: true,
        spriteFilename: './sprites/icons.svg', // this is the destination of your sprite sheet
        publicPath: '/',
      }
    })

Content of extracted Svg file:

export default {
      id: "sprite-01-usage",
      viewBox: "0 0 34.616 34.616",
      url: "/" + "C:\\wamp64\\[...]\\web\\img\\svg-sprites\\sprite-01.svg",
      toString: function () {
        return this.url;
      }
    }

Please tell us about your environment:

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Add a param to omit that information in the extracted file or relate to page root, not the server root.