mrsum / webpack-svgstore-plugin

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

In Webpack-dev-server not work added svg-sprite #152

Open leonidkuznetsov18 opened 7 years ago

leonidkuznetsov18 commented 7 years ago

"webpack": "^2.6.0", "webpack-svgstore-plugin": "^4.0.1"

// in component/Icon.js
import svgxhr from 'webpack-svgstore-plugin/src/helpers/svgxhr';

const __svg__ = {
  path: '../../assets/icons/*.svg',
  name: 'sprite.svg',
};
svgxhr(__svg__);```

// webpack.config.js
const SvgStore = require('webpack-svgstore-plugin');
 new SvgStore(),
`devServer: {
      contentBase: './app',
      publicPath: '/',
      historyApiFallback: true,
      port,
      host,
      hot: !isProd,
      compress: isProd,
      stats,
      proxy: useProxy ? proxy : {},
    },

Not added if i use dev server. But if i use build ш рфму sprite.svg. Please help for this issue

rewop commented 7 years ago

I think I have the same issue. My svgs are not loaded when I use react storybook. And react storybook uses webpack-dev-server.

As far as I see, in the generated bundle the variable __svg__ is not overwritten, and the filenameproperty is not added to the options.

This means that the variable url in svgxhr.js file is false.

For some reasons the parser function is never invoked.

collimik commented 6 years ago

I've the same issue and have arrived at the same conclusions as @rewop. I'm running an ejected Create React App.

nelsieborja commented 6 years ago

Came across same issue but managed to get it work by following the suggestion from here