Reputation: 2315
I'm using the Angular CLI to compile my Angular app down to JS and CSS files. I'm using ng build --environment prod
to compile.
When looking at the index.html
file in the dist
folder, I see that the JS and CSS files are linked properly like so:
<script type="text/javascript" src="script.js"></script>
But then when I open the index.html
file, Safari complains that these files aren't found. But when I edited the HTML file like so:
<script type="text/javascript" src="file:///Users/me/proj/dist/script.js"></script>
Everything works... How can I fix this? Here's how the dist
folder looks like, roughly.
dist
|--------- index.html
|--------- styles.css
|--------- script.js
Upvotes: 0
Views: 547
Reputation: 122
I solved that problem like this.
ng build --prod --base-href /dist
Upvotes: 0
Reputation: 60548
The dist
folder is meant to be deployed to a production server ... not run directly from your system.
As part of the ng build --prod you can specify the base URL to use for your production server. That defines where it will find the files.
ng build --prod --base-href myProductionServerFolder
Upvotes: 2