带有混合应用程序 ng-build 的 Angular CLI [英] Angular CLI with Hybrid app ng-build
问题描述
我目前正在使用 Angular CLI 将 AngularJS 应用升级为 Angular 应用.
I'm currently upgrading an AngularJS app to an Angular app, using Angular CLI.
我的问题是,当我使用 ng build
构建应用程序时,它会将所有文件复制到 dist
文件夹,但会忽略所有 AngularJS 文件.对于所有 js 文件,我的解决方案是将它们添加到 angular-cli.json
中的 scripts
数组中.现在,我只需要处理 html 文件.对于 Angular 应用程序,angular cli 将自动为我处理它们,但 AngularJS 的将保留在 dist
文件夹之外.我想出的一个解决方案是将它们添加到 assets
数组中.所以基本上我有两个问题:
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:
有没有办法让 angular cli 从某个文件夹构建所有
.html
文件?类似的东西:"assets": [应用程序/ng1/.*html"]
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" ]
这是最佳实践吗?或者有没有更好的方法来实现我想要的?
Is this best practice? or is there a better way to achieve what I want?
谢谢!
推荐答案
我找到了第一个问题的解决方案:在 assets
数组中,我没有放置 html
文件的普通路径,而是使用了 glob:{ "glob": "**/*.html", "input": "./app/ng1", "output": "./app/ng1" }
而使用 **
将选取 /app/ng1
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
这篇关于带有混合应用程序 ng-build 的 Angular CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!