Suman
Suman

Reputation: 373

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

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.

Upvotes: 0

Views: 191

Answers (4)

NFT Master
NFT Master

Reputation: 1510

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.

Upvotes: -1

NFT Master
NFT Master

Reputation: 1510

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';

Upvotes: 0

爬起来雨哥
爬起来雨哥

Reputation: 13

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

Upvotes: 1

HSchmale
HSchmale

Reputation: 1929

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

Upvotes: 0

Related Questions