Search code examples
javascriptangularproductionangular7

Angular 7 production build does not load styles and js


I have a small project written in Angular 7 and im trying to build the production version out of it.

When i run

ng build --prod --aot --service-worker

The build will run without errors as seen on screenshot.

enter image description here

On the other hand, when im trying to load the app in the browser, it will throw errors in console and will not load at all.

enter image description here

Any ideas what is causing this? The files are in the same directory as the index.html and they do exist.


Solution

  • So, I figured out that if I want to serve this files statically without using some sort of server in front of the page, I have to set build parameter --base-href ./and also use relative paths for the assets like images.

    So the build command will actually be

    ng build --prod --aot --service-worker --base-href ./