Angular CLI with Hybrid app ng-build

2019-07-27 23:04发布

问题:

I'm currently upgrading an AngularJS app to an Angular app, using Angular CLI.

My problem is that when I build the app using ng build, it would copy all the files to the dist folder but will ignore all the AngularJS files. For all the js files, my solution was to add them to the scripts array in the angular-cli.json. Now, I just need to handle the html files. For the Angular app, angular cli will handle them automatically for me, but the AngularJS ones will stay outside the dist folder. A solution I came up with, was to add them to the assets array. So basically I have two questions:

  1. Is there a way where I can tell angular cli to build all .html files from a certain folder? something like that: "assets": [ "app/ng1/.*html" ]

  2. Is this best practice? or is there a better way to achieve what I want?

Thanks!

回答1:

I found a solution for my first question: In the assets array, instead of putting the plain path of the html files, I used glob: { "glob": "**/*.html", "input": "./app/ng1", "output": "./app/ng1" } while using ** will pick all the sub-directories in /app/ng1