Serving and testing a bundle after ng build

前端 未结 3 1291
鱼传尺愫
鱼传尺愫 2021-02-13 03:43

After I build a bundle with ng build --prod --aot I would like to quickly serve it locally. Is there a way to quickly serve the /dist directory locally

相关标签:
3条回答
  • 2021-02-13 03:49

    http-server is what I use, and it works well.

    Install:

    npm install -g http-server
    

    cd into your dist folder, type http-server, then enter. Or, just do http-server .\dist at the command line after your application build is successful.

    Open a browser, and go to http://127.0.0.1:8080

    More info: https://www.npmjs.com/package/http-server

    I use this on all my dev machines for running built ng applications.

    Or, was there more than simply seeing if the application runs (smoke test) that you were looking for in this?

    0 讨论(0)
  • 2021-02-13 03:50

    to test easily built angular app I use this angular-http-server

    to install it you can do

    npm install -g angular-http-server
    cd /path/to/site/dist/site
    angular-http-server
    

    if you need more info you can check the package npm page angular-http-server

    0 讨论(0)
  • 2021-02-13 03:57

    Following did the trick for us:

    ng serve --configuration production 
    

    If running the Angular development server that way the production configuration is used and you can observe the results.

    We also encountered that when building the application for production the --prod flag was not enough we needed to explicitly set the --configuration option to production for referencing the correct configuration files.:

    ng build --configuration production
    
    0 讨论(0)
提交回复
热议问题