What’s the best practice for image assets in Ionic 2? I have a bunch of SVGs I want to use as non-system icons. I found some older tips on using Gulp but it seems Ionic team has decided on Rollup as the build tool of choice, no docs on this so far.
Somebody told me to just add them to www/img
. Any downsides?
Placing your images in www/img
sounds like a good ideal but it will only work when serving locally using ionic serve
.
When building your app, the www/img
will get deleted unless you make a gulp task to copy the images from the folder you want to the www/build
folder as shown in this post.
Images used in html files should be in src/assets/img
(recommended) and not www/assets/img
(obselete). Image tags would then look like this :
<img src="assets/img/yourimage.jpg" alt="your image">
In ionic 2, the src/assets
folder is meant for images and fonts.
This is what the ionic team says in the guide to modify an existing ionic project :
Move www/img to src/assets/img.
Move any other resources you have in www/ to src/assets/.