ng2-admin aot build unable to fetch images, fonts from assets

190 views Asked by At

I am using ng2-admin template following their installation guide https://akveo.github.io/ng2-admin/articles/002-installation-guidelines/ it is running perfectly in local but when I am creating production build using "npm run build:prod:aot" and running it on server the project is able to fetch js files but all assets getting 404. I have tested by defining base href in index.html but uanble to resolve the issue.

4

There are 4 answers

0
HSchmale On

Have you checked if the assets actually exist on the server? Are the assets getting copied to the build directory and deployed?

0
爬起来雨哥 On

Just updated two files below: 1. src/app/theme/sass/conf/_variables.scss

$assets-root: '{replace to your path}/assets';

2.src/app/theme/sass/_icons.scss

@include svg-icon('{replace to your path}/assets/img/' + $iconName + '.svg', $width, $height);

Enjoy it

0
NFT Master On

I had a similar issue, so I changed the file "_ng2.scss" to the following:

line 68:  $mainBgUrl: "../../" + $assets-root + $images-root + 'sky-bg.jpg';
1
NFT Master On

I found the solution at last.

Please edit "package.json" to the following image.

I added line 29:

Here I deployed to http://localhost/ng2admin/dist on my local machine.

And then:

C:\xampp\htdocs\ng2admin> npm run build:demo

This was my final solution.