Sunday, October 18, 2020

Run Angular dist folder locally using http-server

http-server is a simple, zero-configuration command-line http server used for running html static files in the localhost.

  1. Setup an angular docker application as per previous article http://millionvisit.blogspot.com/2020/10/docker-assignments-19-dockerizing.html
  2. change command as "npm run build" in docker-compose.yml
  3. run docker-compose up command  to generate dist folder in the host machine
  4. install http-server globally by using
          > npm install -g http-server

     5.  navigate to dist folder directory and run following command with default port 8080
    
         > http-server dist/docker-angular

     6. check http://localhost:8080/
     7. index.html file will be served as default file
     8. run following command if you want to change port number

> http-server -p 8022 dist/docker-angular 

     9. check http://localhost:8022/

http-server supports wide range of options like Https, SSL, CORS, basic authentication, request caching and etc.


Happy Coding :)

No comments:

Post a Comment