Run Angular2 as static app in browser without a server

后端 未结 6 1845
日久生厌
日久生厌 2020-12-13 02:06

As I understand the Angular2 concept - it is transpiling TypeScript files to .js files. In principle, it should be possible to compile, package, and then run that Angular2 a

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 02:53

    What helped me was,

    1. Run an ng build --prod --base-href ./ in the app route directory and generate the dist/ files
    2. In the dist/ directory, edit the index.html to remote the type="module" and nomodule defer attributes from the scripts.

      Ex:

      
      
      

      should be changed to,

      
      
      

    Now you should be able to render the index.html file in a browser.

提交回复
热议问题