标签: angular-cli

有没有办法将图像部署到 Firebase 托管,但仅限于存在更改的地方?

我将我的 Angular2 站点部署到 Firebase 托管,但“dist”文件夹总是在“assets”文件夹中发送整个图像集合,即使它们没有改变。这会占用不必要的带宽,因为此文件夹比所有其他文件的总和还要大。

如何仅部署更改的图像?策略是:

A)配置 Firebase CLI“部署”命令以仅处理更改的图像

和/或

B)将 Angular 生产版本配置为仅打包更改的图像(尽管这仍然需要 Firebase 更新“资产”文件夹,而不是覆盖所有其他未更改的部署图像)

正如我所见,Firebase Storage 不是一个好的替代方案……在页面加载时调用 API 来访问图像只会减慢加载时间……除非这涉及缓存策略?归根结底,该解决方案需要让 CDN 和 CLI 协同工作,以最大限度地减少带宽和加载/部署时间。

firebase firebase-hosting angular-cli firebase-storage angular

1
推荐指数
1
解决办法
2402
查看次数

使用 --watch 构建的 angular-cli 不观看

我遇到了一个问题,在 Ubuntu 17.04 上,@angular/cli@1.3.2命令ng build --watch在构建应用程序(成功)后退出并且没有开始观看。ng serve虽然工作正常并启动观察者。

我发现的最相似的问题是通过通过-opoption 或outDirproperty in设置输出路径来解决的,.angular-cli.json在我的情况下,这些似乎都没有帮助。关于可能是什么原因的任何想法?

更新

我的错,ng serve只是没有停止进程,观察者仍然没有工作。

angular-cli

1
推荐指数
1
解决办法
1543
查看次数

Angular 4 - 在组件内向 svg 添加类和路径?

Angular 4位于组件内时,如何在 SVG 中动态添加类和路径?

在我的组件中,当我将以下代码粘贴到组件模板中时,图标有效;

<svg class="another-class iconId">

<use xlink:href="/icon-path/def.svg#iconId"></use>

</svg>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试绑定这样的类时:

<svg class="another-class {{iconId}}">

<use xlink:href="/icon-path/def.svg#{{iconId}}"></use>

</svg>
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Error: Template parse errors:
Can't bind to ':xlink:href' since it isn't a known property of ':svg:use'
Run Code Online (Sandbox Code Playgroud)

四处搜索后,我发现了将代码更改为以下内容的建议:

<svg class="another-class {{iconId}}">

<svg:use [attr.xlink:href]="/icon-path/def.svg#{{iconId}}"></svg:use>

</svg>
Run Code Online (Sandbox Code Playgroud)

有了这个,我得到以下错误:

Uncaught (in promise): Error: Template parse errors:
Parser Error: Got interpolation ({{}}) where expression was expected at column 30 in [/icon-path/def.svg#{{iconId}}]
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么?

编辑:按照 Noodle 的建议尝试以下操作:

<svg class="another-class {{iconId}}">

<use [attr.xlink:href]="'/icon-path/def.svg#' + iconId"></use>

</svg>
Run Code Online (Sandbox Code Playgroud)

仍然收到以下错误: …

svg angular-cli angular

1
推荐指数
1
解决办法
4343
查看次数

可以将角度环境变量插入到 scss 中吗?

我正在尝试找到一种方法来更改scss基于“配置文件”变量环境的编译方式。我的应用程序将安装在不同的位置,不同主题的女巫,但都是css一样的。我只需要color palette在编译期间更改将使用的内容。我的应用程序已经有了environments.tsaprofile变量,它将用于brand image.

我在想这样的事情:

export const environment = {
  production: true,
  profile: 'appX'
  apiUrl: 'http://mydoainX.com/api/',
};
Run Code Online (Sandbox Code Playgroud)

并且,在scss

$profile: environment.profile;
Run Code Online (Sandbox Code Playgroud)

有可能做这样的事情吗?

有什么想法吗?

sass angular-cli angular

1
推荐指数
1
解决办法
5863
查看次数

当 angular-cli 报告错误时,TeamCity 构建失败

我正在尝试配置团队城市以运行 angular 5 应用程序构建。我有这个脚本的 powershell 步骤(它在构建步骤定义中,而不是单独的文件中)。npm run buildng build

npm install
npm run build
Run Code Online (Sandbox Code Playgroud)

出于某种原因,即使ng build团队城市建设失败也不会失败。来自的状态代码npm run不会传播回 powershell。

请参阅以下屏幕: 在此处输入图片说明

teamcity npm angular-cli

1
推荐指数
1
解决办法
819
查看次数

在 program.d.ts 中找不到模块“路径”

运行 ng serve 时,我的代码无法编译并出现此错误:

node_modules/@angular/compiler-cli/src/transformers/program.d.ts(9,23) 中的错误:错误 TS2307:找不到模块“路径”。

我认为这与我的本地 angular 版本比我的全局版本旧版本有关,所以我尝试了这个解决方案

但这没有帮助。现在要编译我的代码,我必须删除一个 ';' 在我的项目中随机的某个地方,保存项目,添加分号并保存项目。使用这种方法,我的代码可以编译并且我的应用程序可以运行,但错误仍然存​​在。

path node-modules angular-cli angular

1
推荐指数
1
解决办法
2299
查看次数

如何使用 Junit 在 Jenkins 中显示 Angular Lint 输出?

如何在 Jenkins 中显示“npm lint”结果?我知道如何在 Jenkins 中显示“pytest”结果:

  1. 像这样运行 pytest: pytest --junitxml=./path/to/pytestFile.xml ./path/to/code
  2. 运行这个 Jenkins 命令: junit testResults: "./path/to/pytestFile.xml"

一旦我这样做了,我的测试结果就会出现在 Jenkins 的“测试结果”窗口中。我想对我的 angular lint 结果做类似的事情。我尝试这样做,但没有用:

  1. 像这样运行 linter: npm lint --junitxml=./path/to/lintFile.xml
  2. 运行这个 Jenkins 命令: junit testResults: "./path/to/lintFile.xml"

问题是 npm 没有 --junitxml 开关。我怎样才能做到这一点?我正在使用 Jenkins 声明式管道。

junit lint jenkins angular-cli jenkins-declarative-pipeline

1
推荐指数
1
解决办法
2667
查看次数

Angular CLI 错误:端口 80 已在使用中。使用“--port”指定不同的端口

尝试构建 Angular 应用程序并使用以下命令启动 Web 服务器时(操作系统:Ubuntu):

ng serve --port 80
Run Code Online (Sandbox Code Playgroud)

显示以下错误:

端口 80 已在使用中。使用“--port”指定不同的端口。

angular-cli

1
推荐指数
1
解决办法
1466
查看次数

当我使用命令 npm start 运行 Angular 应用程序时会发生什么

我是网络编程的新手。我按照教程使用 Angular CLI 创建了一个简单的网络应用程序,然后据说我可以使用命令在本地运行该应用程序npm start

它起作用了,我的应用程序正在运行localhost:4200

如何npm start运行我的应用程序?

我还想知道使用什么样的服务器来托管我的应用程序,因为我没有创建任何 Web 服务器(例如:Nodejs 服务器等)。

有没有办法自定义这个服务器,比如更改端口号?

Ps:我正在使用 Angular 6

node.js angular-cli angular

1
推荐指数
1
解决办法
670
查看次数

为什么安装版本 7 后 Angular CLI 版本显示为 1?

我正在尝试将我的 Angular CLI 全球版本更新到最新版本。

为什么ng v安装后还是不显示1.3.2版本?

我正在使用nvm顺便说一句。


安装前...

$ng -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / ? \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

1
推荐指数
1
解决办法
848
查看次数