webpack-svgstore-plugin
webpack-svgstore-plugin copied to clipboard
In Webpack-dev-server not work added svg-sprite
"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
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 filename
property 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.
I've the same issue and have arrived at the same conclusions as @rewop. I'm running an ejected Create React App.
Came across same issue but managed to get it work by following the suggestion from here