-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work with webpack-dev-server #19
Comments
+1 I'm having the same issue @jefvlamings. It's looking in dist/ which is the problem. Any ways to fix this? How do we make it look in src when on webpack-dev-server and dist/ when built? |
Setting
Then set your src path relative to your package.json file. e.g,
so your path will be |
@antesgeist It is not working even with
The only thing it is doing is replacing Maybe I have some incompatible webpack.config.js settings. Which were yours? |
Does someone manage to fix this? When I build the project it works fine, but in the Dev Server it's just a regular 'img' tag. |
@juanramoncarceles Didn't see the notifications for this man, but yeah, it is still working on my previous project. It might indeed be a Webpack config issue based on your as I see the plugin isn't picking up the correct project path for your SVG. See below for further instructions if you're still trying to get this working. -- Here's my relative project repo with this SVG plugin setup. https://github.com/antesgeist/todd. Tested it just now and it's still working. Dev server: npm start Check over my comments on my webpack config and see how the rest of the config/directories are setup. I've run into similar pathing issues before and tested different config types, found this one below that works for my setup. webpack.config.js [loaders/svg]
webpack.config.js [plugins]
On my setup, I am pulling SVG assets from node_modules packages but you can also use directories relative to your html template as noted on the snippet above. Here's how you can do so: -- From node_modules folder.: The tilde "~" prefix signifies that you are looking in the node_modules directory, I think this is default webpack behaviour.
-- From template relative directories. e.g, HTML template: src/public/index.html
|
I'm facing the same issue. I've managed to fix it with |
I agree it does look verbose if you have to pass the full path, but as mentioned on my previous reply, you can use this plugin without specifying the project root path by letting Webpack handle the path resolution. Simply configure your SVG loader like this:
Then you use your SVG assets like this: template: src/public/index.html
|
hey all, if anyone has a better method than the I'll close this for now, but if someone is able to push a PR with a better alternative that would be awesome. |
All this confusion with Now the documentation has been refactored and it better reflects the three ways SVG files can be referenced:
Documentation now also has a new |
This plugin assumes that images are written to disk. When running webpack-dev-server the assets are not copied to the destination folder and therefor will not be able to be read.
The
fs.readFile
throws an error because it's not finding the image in the destination folder:Please note that the plugin is working fine when just building with webpack.
The text was updated successfully, but these errors were encountered: