How to get angular-cli live reload working with my web server

I need to figure out how to get live reload to work with my local web server. I use vagrant to host my project at http: //admin.myproject.local and using angular-cli to build my application.

When using npm start I can view my changes live on http: // localhost: 4200 , but nothing changes on my admin.myproject.local until you complete the build. I looked through the angular-cli docs and thought a proxy would be the solution. I created the proxy.conf.json file and added the following code:

 { "/admin": { "target": "http://admin.myproject.local", "secure": "false" } } 

However, this does not seem to help. If I try http: // localhost: 4200 / admin , I get 404.

Can someone point me in the right direction to make a live reboot work when accessing the site through my .local url?

+5
source share
1 answer

You can create another HTML file (or use an existing server index file) and point the script tags to the generated js files. For instance..

 <!doctype html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <base href="/"> </head> <body> <my-app></my-app> <script src="http://localhost:4200/inline.js"></script> <script src="http://localhost:4200/scripts.bundle.js"></script> <script src="http://localhost:4200/main.bundle.js"></script> </body> </html> 

It works for development. And for production, they include script files from the dist directory after running ng build -prod .

+1
source

Source: https://habr.com/ru/post/1257659/


All Articles