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.
Asked
Active
Viewed 183 times
4 Answers
1
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

爬起来雨哥
- 13
- 1
- 4
0
Have you checked if the assets actually exist on the server? Are the assets getting copied to the build directory and deployed?

HSchmale
- 1,838
- 2
- 21
- 48
0
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';

JonathanDavidArndt
- 2,518
- 13
- 37
- 49

NFT Master
- 1,400
- 12
- 13
-1
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.

double-beep
- 5,031
- 17
- 33
- 41

NFT Master
- 1,400
- 12
- 13
-
Please add code and data as text ([using code formatting](//stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](//meta.stackoverflow.com/a/285557). In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. – double-beep May 09 '19 at 20:21