webpack-svgstore-plugin icon indicating copy to clipboard operation
webpack-svgstore-plugin copied to clipboard

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

Open leonidkuznetsov18 opened this issue 7 years ago • 3 comments

"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

leonidkuznetsov18 avatar Aug 23 '17 09:08 leonidkuznetsov18

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.

rewop avatar Aug 23 '17 12:08 rewop

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

collimik avatar Oct 13 '17 12:10 collimik

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

nelsieborja avatar Jan 07 '18 13:01 nelsieborja