标签: angular-cli

Angular-CLI服务于Lint Watch

ng lint在观看文件更改期间有没有办法运行ng serve?为了鼓励根据Angular 2样式指南的最佳实践,我们的CI工具ng lint在构建过程中运行,并且并不总是开发人员首先想到在提交拉取请求之前运行lint.

是否可以自定义ng serve在重新编译过程中包含运行lint的方法或者有没有人想出的方法?如果没有,我也有兴趣知道其他人是否对这是否是一个好主意以及为什么有任何意见.

tslint angular-cli angular

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

EXCEPTION:未捕获(承诺):错误:找不到模块'app/home/home.module'

我正在尝试使用路由器延迟加载Angular 2模块,我遇到了这个错误:

error_handler.js:50 EXCEPTION:未捕获(在承诺中):错误:找不到模块'app/home/home.module'

我尝试了所有似乎对其他人有用的答案,比如这个似乎是每个人都面临这个问题的解决方案,但是不适用于我在Angular2 RC7和angular-cli webpack中加载Lazy

这是我的代码:app.module

import { MediatorService } from './home/mediator.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';


import appRoutes from "./app.routes";


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    appRoutes
  ],
  providers: [MediatorService],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

app.routes

import { RouterModule } from …
Run Code Online (Sandbox Code Playgroud)

lazy-loading webpack-dev-server angular2-routing angular-cli angular

13
推荐指数
6
解决办法
3万
查看次数

angular-cli新项目中的webpack.config.js在哪里?

我正在研究webpack和angular-cli,即使angular-cli应该使用webpack,webpack.config.js当我创建一个新项目时,我看不到任何文件ng new

有人知道这在angular-cli中是如何工作的吗?

webpack angular-cli

13
推荐指数
2
解决办法
1万
查看次数

如何使用配置指定ng e2e的端口和主机

如何ng e2e使用配置文件为命令设置端口和主机?

我知道可以在命令行中使用以下语句

ng e2e --port <port number> --host <host>
Run Code Online (Sandbox Code Playgroud)

这很好用,但在配置文件中设置端口和地址会更方便.我已经查看了内部.angular-cli.json,发现有一个文件被调用protractor.config.js,我无法弄清楚在该文件中使用的baseUrl设置,有一个设置,但是更改它对使用的端口没有任何影响ng e2e命令.它似乎使用随机端口.

除了baseUrl我也试过设置port,seleniumPort但他们没有任何区别.

输入ng e2e命令后,控制台中将显示以下输出

** NG Live Development Server is running on http://localhost:49155 **
Run Code Online (Sandbox Code Playgroud)

在protractor.config.js我已经baseUrl设定为http://localhost:50000.我观察到测试正在执行,我可以看到浏览器使用的地址http://localhost:49155不是我想要的地址.

ng --version 返回以下内容

@ angular/cli:1.0.0
节点:7.7.1
os:win32 x64
@ angular/common:4.0.3
@ angular/compiler:4.0.3
@ angular/core:4.0.3
@ angular/forms:4.0.3
@ angular/http:4.0.3
@ angular/platform-b​​rowser:4.0.3
@ angular/platform-b​​rowser-dynamic:4.0.3
@ angular/router:4.0.3
@ angular/cli:1.0.0
@ angular/compiler- …

protractor angular-cli angular

13
推荐指数
4
解决办法
9532
查看次数

如何在SASS中使用Angular 4

我正在使用Angular4和开始我的第一个项目,sass并且我正试图弄清楚如何以sass正确的方式工作.我正在使用angular-cli并已设置默认样式以使用scss语法.我也已经定义了编译等.

但是我看到组件上有一个选项styleUrls,在某些情况下我们定义仅在该组件中使用的样式.

问题是,当我设置一个scss文件时,component它不会生成它自己的.css文件,既不包含在主.css文件中,而是从根项目生成的.

所以基本上我有一个像这样的项目结构:

app
    app.module.ts
    app.routing.ts
    home
        home.component.ts
        home.html
        _home.scss
    client
        client.component.ts
        client.html
        _client.scss
scss
    _imports.scss
    colors
        _colors.scss
    ui
        _button.scss
        _table.scss
    //.. more folder and files
styles.scss
index.html
Run Code Online (Sandbox Code Playgroud)

我希望能够css在styles.scss文件中设置主要样式,index.html稍后将在构建过程中将其插入到文件中.但也能够生成一个单一的css每个组件我有,如文件home和client,并且只使用那些css自己份内的风格component.

有可能吗?我试过这个,我没有找到任何关于此的其他资源!

css sass css-preprocessor angular-cli angular

13
推荐指数
2
解决办法
2万
查看次数

Angular CLI - Typescript throws:无法读取未定义的属性"length"

我使用ng服务运行角度4项目,我得到错误

Cannot read property 'length' of undefined
Run Code Online (Sandbox Code Playgroud)

但我的项目中没有任何属性长度..

完整的错误

    Your global Angular CLI version (1.2.1) is greater than your local
version (1.1.3). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at createSourceFile (E:\?????????\????????? ???\Angular 4\Youtube Channel Angular Firebase\full project of the instructor github\angular-firestarter-master\node_modules\typescript\lib\typescript.js:15457:109)
    at parseSourceFileWorker (E:\?????????\????????? ???\Angular 4\Youtube Channel Angular Firebase\full project of the instructor github\angular-firestarter-master\node_modules\typescript\lib\typescript.js:15389:26)
    at Object.parseSourceFile (E:\?????????\????????? …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

13
推荐指数
4
解决办法
2万
查看次数

使用Angular CLI 1.6.0时,服务器使用什么服务器?

使用Angular CLI 1.6.0时,此Angular CLI命令使用什么服务器?

ng serve
Run Code Online (Sandbox Code Playgroud)

由于Angpack CLI正在使用webpack进行网站捆绑,这是否意味着ng-serve正在使用webpack-dev-server(这是一个Node.js Express服务器)?在下面的Q/A中有一些迹象表明ng服务可能用于搭载Ember使用的服务器:

ng serve
Run Code Online (Sandbox Code Playgroud)

build-tools angular-cli angular

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

你如何调试Angular 6库

我正在写一个Angular 6图书馆,无法弄清楚如何进入打字稿.

我用以下方法生成了应用: ng new mylibapp

然后我使用以下方法添加了库: ng g library @abc/cool-lib -p abc

当我表演时: ng build @abc/cool-lib

它会在mylibapp/dist/abc/cool-lib文件夹中生成代码

我现在如何调试此代码并在位于的ts文件中设置断点 mylibapp/projects/abc/cool-lib/src/lib

typescript angular-cli angular ng-packagr angular-cli-v6

13
推荐指数
5
解决办法
4700
查看次数

从现有项目构建角度元素

我们有一个现有的Angular 8项目,其中包含许多常用组件(例如custom datepickers, numeric inputs, ...)。该项目本身是一个标准的Angular应用程序。

我们希望将其中一些组件提取为Angular元素,以便可以在其他Angular应用程序甚至与Angular不相关的其他项目中使用。

是否可以通过仅在生成的JavaScript文件中包含特定于单个Angular元素的代码的方式构建项目?

我需要的是这样的: ng build --element myDatePicker

这应该myDatePicker-Element只为所有具有所有所需依赖项的项目生成所有JavaScript文件,而无需从项目中获取任何其他代码(如other components, modules, ...)。

使用时,整个应用仍应正常构建ng build。

angular-cli angular angular-elements

13
推荐指数
3
解决办法
668
查看次数

stylePreprocessorOptions angular 8

我正在按照此操作通过 Angular 8 中的 stylePreprocessorOptions 添加可导入的 scss 文件,但我不断收到未找到它的错误。任何输入都值得赞赏,这个巧妙的技巧非常有用!

下面是我的 angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "thebearcottages-app": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss",
          "skipTests": true
        },
        "@schematics/angular:class": {
          "skipTests": true
        },
        "@schematics/angular:directive": {
          "skipTests": true
        },
        "@schematics/angular:guard": {
          "skipTests": true
        },
        "@schematics/angular:module": {
          "skipTests": true
        },
        "@schematics/angular:pipe": {
          "skipTests": true
        },
        "@schematics/angular:service": {
          "skipTests": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular-cli angular

12
推荐指数
2
解决办法
2万
查看次数