mrsum / webpack-svgstore-plugin

Simple svg-sprite creating with webpack
https://www.npmjs.com/package/webpack-svgstore-plugin
200 stars 90 forks source link

Calling wrong url to the svg file on production #130

Open iamrane opened 7 years ago

iamrane commented 7 years ago

When i try it on dev it works perfect, when Im trying this on production its calling with a weird url. https://www.mydomaincom/https://www.mydomaincom/static/1487869309421.icons.svg

webpack.base.js

var SvgStore = require('webpack-svgstore-plugin');
var plugins = [
new SvgStore.Options({
  svgoOptions: {
    plugins: [
      { removeDesc: true },
      { removeAttrs: { attrs: 'fill|class|style' } },
      { removeStyleElement: true },
      { removeRasterImages: true },
     { sortAttr: true }
  ]
}})

in my js

var __svg__ = {path: '../../../styles/images/svg-icons/**/*.svg', name: '[hash].icons.svg'};
require('webpack-svgstore-plugin/src/helpers/svgxhr')(__svg__);
nadavsinai commented 7 years ago

you need to set a base url tag in your html

nadavsinai commented 7 years ago

my mistake, looking at the code it seems that the public url by webpack config is what's used here, so set that accordingly see https://github.com/mrsum/webpack-svgstore-plugin/pull/110/commits/37880b357bddead285a046e8abbaef1f318c93dd

jarodtaylor commented 7 years ago

I'm having this same issue and @nadavsinai I'm not quite sure I understand what your solution is/was.