ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
128 stars 85 forks source link

Correct absolute assets path on all builds? #408

Open ionitron-bot[bot] opened 5 years ago

ionitron-bot[bot] commented 5 years ago

Original issue by @Domvel on 2018-02-16T18:31:42Z

What is the correct path for assets reference on ALL build? In css I use some image like:

background-image: url(/assets/imgs/icons/close.svg);

This works with ionic serve and ionic cordova run android -lc but not with ionic cordova run android --prod.

I also have problems with relative path. Look at this lines and comments. Tested in ionic serve mode (also with cleared cache)

/* These lines doesn't work. */
-webkit-mask-image: url(assets/imgs/icons/close.svg);
-webkit-mask-image: url(./assets/imgs/icons/close.svg);

/* These lines works. */
-webkit-mask-image: url(/assets/imgs/icons/close.svg);
-webkit-mask-image: url(../assets/imgs/icons/close.svg);
-webkit-mask-image: url(../../assets/imgs/icons/close.svg);
-webkit-mask-image: url(../../../assets/imgs/icons/close.svg);
-webkit-mask-image: url(../../../../assets/imgs/icons/close.svg);
/* and so on. why? */

I'm looking for a always-working-path in every style-file. Also for src-references in html-tags and http-get, to load assets.

Some console prints of the prod build viewed with chrome developer tools remote device inspector.

Filed to load resource:
file:///android_asset/www/assets/fonts/roboto-regular.woff2
...
Failed to load resource:
file:///assets/imgs/icons/close.svg

Don't know why the font is missing? Is it a ionic request? In production build, the icon resources from assets can't load. (css url(path))

rizz360 commented 5 years ago

Any news on this?

BVBAccelm commented 5 years ago

I'm also trying to figure this out. My asset paths are inconsistently working when I use ionic serve in a browser, vs building for android and running it on a devices, vs building for ios on a simulator. Similarly to the original issue, I am trying to figure out the best practice for where to put my assets and how to link them from these scss files.