0

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

2 Answers 2

2

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
Sign up to request clarification or add additional context in comments.

Comments

0

I solved that problem like this.

ng build --prod --base-href /dist

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.