我正在使用 angular5 开发一个应用程序,通过 ng-cli 使用服务工作者,但我意识到在第一次加载应用程序外壳后,它不会刷新。使用ng build?构建应用程序后,如何将新文件版本推送到我的应用程序。我可以直接手动重写 sw.js,但是因为它是通过 cli 生成的,所以我不喜欢影响任何我不知道是做什么的。
我整天都在寻找这个答案,但由于服务工作者是 1.6 版 ng-cli 的新成员,我没有找到任何答案。
我什至在 ng-cli 1.6 之前找到了一个与 angular 4 和非官方 Service Workers 实现类似的线程,但我不相信这种方法,因为它不是官方的,所以我想知道你们是否可以帮我找到一种控制外壳安装方式和寻找新版本的方法。
谢谢
service-worker progressive-web-apps angular-cli angular5 angular-service-worker
我正在为 angular 构建一个组件库,我们将在项目之间共享它。但是当我构建包时,html 文件不会被复制到 dist 文件夹中。我收到错误angular Failed to load text-input.component.html。
这是我的 tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
},
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts"
]
}
Run Code Online (Sandbox Code Playgroud)
这是编译后的组件:
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) …Run Code Online (Sandbox Code Playgroud) 我已经使用以下设置对我现有的 angular cli 应用程序进行了docker化:
根级dockerfile:
# Create a new image from the base nodejs 7 image.
FROM node:7
# Create the target directory in the imahge
RUN mkdir -p /usr/src/app
# Set the created directory as the working directory
WORKDIR /usr/src/app
# Copy the package.json inside the working directory
COPY package.json /usr/src/app
# Install required dependencies
RUN npm install
# Copy the client application source files. You can use .dockerignore to exlcude files. Works just as .gitignore does.
COPY . …Run Code Online (Sandbox Code Playgroud) 我需要帮助。我是一个完整的初学者,我在任何地方都找不到解决方案,很抱歉,如果已经有人问过了,但是无论我尝试什么,我都无法在一页上显示背景图像。
我想做的事?
在主页上显示背景图像。
笔记:
由于我的根目录中没有 assets 文件夹,我在 src 文件夹中创建了一个。
结构:
? node_modules
? src
? app
? components
? home
home.component.html
home.component.scss
home.component.spec.ts
home.component.ts
? assets
? images
? bg.jpg
Run Code Online (Sandbox Code Playgroud)
.angular-cli.json
"assets": [
"assets",
"images",
"favicon.ico"
],
Run Code Online (Sandbox Code Playgroud)
主页.component.scss
.homeBg {
background-image: url('../../../assets/images/bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
width: 100vw;
height: 100vh;
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我并告诉我我做错了什么吗?我花了将近 3 个小时试图弄清楚这一点。
提前致谢。
所以让我们有以下模块
现在,SharedModule并MaterialModule加载了 main AppModule。两者都用于CustomModules. 这些惰性模块的捆绑包包含SharedModule并且MaterialModule尽管这 2 个模块已加载到应用程序引导程序中。
有没有办法让“编译器知道”将提供给定的依赖项并且不需要将它包含在给定的包中?(如provided范围 in Maven)
我一直在尝试使用最新的 CLI 在 Angular6 中创建一个新项目,但一直无法更新。为了解决这个问题,我只是试图删除 Angular CLI 并重新开始,但即使这样也行不通!
从一个随机文件夹(其中没有项目),如果我运行ng -v我得到
Angular CLI: 1.5.4
Node: 9.4.0
OS: darwin x64
Angular:
...
Run Code Online (Sandbox Code Playgroud)
我很容易尝试运行以下命令;
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm uninstall -g @angular/cli
npm cache verify
Run Code Online (Sandbox Code Playgroud)
然后另一个ng -v,我希望它抱怨没有找到 ng ,而是显示相同的东西!
Angular CLI: 1.5.4
Node: 9.4.0
OS: darwin x64
Angular:
...
Run Code Online (Sandbox Code Playgroud)
我在想这可能与我使用 NVM 来管理我的 Node 版本有关,但我找不到任何东西。
我也试过 npm install -g @angular/cli@latest上述所有内容,但是当我检查我的 ng 版本时,它仍然显示相同的 1.5.4 而不是最新版本。
一些信息;
当我在终端中输入时,我在 MAC 中安装了最新的 Angular 6.0.4:
ng new happiness
Run Code Online (Sandbox Code Playgroud)
展示:
Schematic input does not validate against the Schema: {"dryRun":false,"version":"6.0.4","skipGit":false,"skipInstall":false,"linkCli":false,"commit":true,"newProjectRoot":"projects","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false} Errors:Data path "" should NOT have additional properties(dryRun).
Run Code Online (Sandbox Code Playgroud)
谁能告诉我?非常感谢
我正在使用 Angular 5。
热重载大约需要 8 秒,这是合理的(虽然不是很好)但是有什么方法可以配置它以便我可以调整它以使其更快?
担心随着应用程序的增长它会变得更慢。谢谢。
我为每个客户都有不同的环境设置,每个客户都有自己的 {{custName}}/environment.prod.ts 文件。我想通过 ng build --prod 命令使用它们各自的 prod 环境文件。我面临的问题是即使在指定环境之后它使用默认的 environment.prod.ts
我的package.json有类似的脚本
{.....
customer_a : "ng build --prod --environment=custA_prod",
....}
Run Code Online (Sandbox Code Playgroud)
在angular-cli.json我已经提到了这样的路径
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"qa": "environments/environment.qa.ts",
"custA_prod": "environments/custA/environment.prod.ts"
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用 prod build 的所有功能但具有一些不同的环境设置?
build production-environment package.json angular-cli angular
您好 在 Angular 8 中创建了一个项目。最初它只支持一种默认语言(US-EN)。然后我应用了本地化。
在准备生产构建的本地化之前,我曾经给出以下命令。
ng build --prod --base-href "/Windchill/com/qiwkCollaborator/"
Run Code Online (Sandbox Code Playgroud)
本地化后,我在 angular.json 和 package.json 中做了一些更改。在进行这些更改后,每当我发出任何准备构建它的命令时,都会出现以下错误。
An unhandled exception occurred: Configuration 'production' is not set in the workspace.
Run Code Online (Sandbox Code Playgroud)
Package.json 文件的某些部分如下:
"name": "qwik-collaborator",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-locale:en": "ng build --prod --i18n-locale en --i18n-format xlf --i18n-file src/translate/messages.en.xlf --output-path=dist/en --baseHref /en/",
"build-locale:fr": "ng build --prod --i18n-locale fr --i18n-format xlf --i18n-file src/translate/messages.fr.xlf --output-path=dist/fr --baseHref /fr/"
Run Code Online (Sandbox Code Playgroud)
Angular.json …
angular-cli ×10
angular ×8
angular5 ×2
angular8 ×1
build ×1
docker ×1
hot-reload ×1
livereload ×1
macos ×1
package.json ×1
webpack ×1