mrsum / webpack-svgstore-plugin

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

webpack-dev-server doesn't serve sprite with v4.0 and webpack 2 #133

Open sergek opened 7 years ago

sergek commented 7 years ago

Hi, I've tried v4.0 and webpack2 and I'm having an issue with webpack-dev-sever not serving svg sprite over ajax request (404).

This is string from my app const svg = { path: '/sprite/*.svg', name: '/assets/[hash].sprite.svg' }; require('webpack-svgstore-plugin/src/helpers/svgxhr')(svg);

This is the single string about the sprite file in webpack-dev-server output /assets/1490001270004.sprite.svg 12.4 kB [emitted]

console.log(svg.filename) in runtime returns //assets/1490001270004.sprite.svg

but the actual ajax request for the file always return 404 Cannot GET /assets/1490001270004.sprite.svg

If I run webpack build, then webpack does generate and save sprite to fs no problems, so the problem I have only related to webpack-dev-server and serving the svg from memory.

Any thoughts on how to debug such a behavior? Thanks!

kulaeff commented 7 years ago

Try to use let instead of const.