标签: angular-cli

使用WebPack在Web worker中运行Angular 2应用程序

我正在尝试将Angular 2应用程序的整个执行移动到Web工作者,但我发现现在所有可用的示例都使用System.js,而我正在尝试使用基于WebPack的项目(用angular-cli构建).

有没有人这样做过,或者对如何使用WebPack有所了解?

下面是我的main.ts引导程序文件:

import './polyfills.ts';


import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';


if (environment.production) {
  enableProdMode();
}

import {bootstrapWorkerUi} from '@angular/platform-webworker';
bootstrapWorkerUi('/app/loader.js');
Run Code Online (Sandbox Code Playgroud)

我loader.js看起来像这样:

import {platformWorkerAppDynamic} from '@angular/platform-webworker-dynamic';
import { AppModule } from './app/';

platformWorkerAppDynamic().bootstrapModule(AppModule);
Run Code Online (Sandbox Code Playgroud)

我app.module.ts的声明是@NgModule这样的:

import { NgModule } from '@angular/core';
import {WorkerAppModule} from '@angular/platform-webworker';


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

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    WorkerAppModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
 export class AppModule …
Run Code Online (Sandbox Code Playgroud)

web-worker webpack angular-cli angular

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

将node-sass-json-importer集成到Angular CLI应用程序中

尝试将node-sass-json-importer添加到Angular CLI应用程序中.

我使用1.0.0-beta.17的是CLI 版本,但是还无法使用当前版本来解决1.2这个问题.通过纱线安装后,我不知道应该在应用程序配置中设置它.

有没有人成功地将其整合到他们的应用程 我能找到的唯一答案是使用Webpack的应用程序,而不是Angular CLI.

javascript sass node-sass angular-cli angular

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

关于资产优化的 Angular-cli“JavaScript 堆内存不足”

我正在 Angular-cli 项目中创建传单地图。地图图块本地存储在“资产”文件夹中,因为它是栅格地图。问题是当我有很多缩放级别的地图时,我有超过 28 万张图像,大小大约为 1.1 GB,而且它会变得更大。

当我ng serve在这里使用时是控制台输出(它被卡住了@assets optimization):

** NG Live Development Server is running on http://localhost:4200. **
25234ms building modules
69ms sealing
0ms optimizing
0ms basic module optimization
96ms module optimization
1ms advanced module optimization
16ms basic chunk optimization
0ms chunk optimization
1ms advanced chunk optimization
0ms module and chunk tree optimization
179ms module reviving
9ms module order optimization
4ms module id optimization
6ms chunk reviving
23ms chunk order optimization
36ms chunk id optimization
61ms …
Run Code Online (Sandbox Code Playgroud)

node.js leaflet webpack angular-cli angular

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

Angular 4 CLI找不到名字'jasmine'

我正在使用Angular 4 CLI(v.1.0.0)并处理测试我创建了一些使用jasmine来创建间谍的模拟.在IDE中一切看起来都没问题,但是在我收到的终端和错误中写着"找不到名字'茉莉花'".

起初我认为问题是茉莉没有添加到打字中,但我可以看到package.json包含茉莉花类型def的导入,所以我不确定缺少什么.

mocks.ts

export class MockAuthService {
  public login: Function = jasmine.createSpy('login');
}

export class MockHttpService {
  public delete: Function = jasmine.createSpy('delete');
  public get: Function = jasmine.createSpy('get');
  public post: Function = jasmine.createSpy('post');
  public put: Function = jasmine.createSpy('put');
}
Run Code Online (Sandbox Code Playgroud)

运行ng服务在终端中返回以下错误消息.

C中的错误:/Users/efarley/Desktop/repos/prod/src/app/mocks/mocks.ts(2,23):找不到名字'jasmine'.C:/Users/efarley/Desktop/repos/prod/src/app/mocks/mocks.ts(6,24):找不到名字'jasmine'.C:/Users/efarley/Desktop/repos/prod/src/app/mocks/mocks.ts(7,21):找不到名字'jasmine'.C:/Users/efarley/Desktop/repos/prod/src/app/mocks/mocks.ts(8,22):找不到名字'jasmine'.C:/Users/efarley/Desktop/repos/prod/src/app/mocks/mocks.ts(9,21):找不到名字'jasmine'.webpack:编译失败.

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

tsconfig.spec.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": …
Run Code Online (Sandbox Code Playgroud)

karma-jasmine angular-cli typescript-typings

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

新的angular.json文件的说明和结构(angular-cli 6.x)

角度为6.x的新angular.json文件作为其结构的一部分具有以下内容

"styles": [{
  "input": "src/styles.scss"
}],
"scripts": []
},
Run Code Online (Sandbox Code Playgroud)

我当前的angular/cli v1.72与.angular-cli.json相同

"styles": [
  "../scss/bootstrap/bootstrap.scss",
  "../src/assets/styles/icon8.css",
  "styles.scss",
  "styles-props.css"
],
"scripts": [
  "../node_modules/web-animations-js/web-animations.min.js",
  "../node_modules/jquery/dist/jquery.js",
],
Run Code Online (Sandbox Code Playgroud)

如何将v1.7.2转换为v 6.x格式?新格式的"输入"代表什么?

干杯

angular-cli

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

使用Angular-CLI 6.1.2创建新项目时出错

我尝试使用ng new angular-6-boilerplateangular-cli最新版本创建一个新的Angular项目,但我不能再这样做了.我正在使用windows终端来创建我的项目,但是我收到了这个错误.

原理图输入不对Schema进行验证:{"name":"angular-6-boilerplate","version":"6.1.2","newProjectRoot":"projects","skipInstall":false,"linkCli": false,"skipGit":false,"commit":null}错误:

  Data path ".name" should match format "html-selector".
Run Code Online (Sandbox Code Playgroud)

为什么我收到此错误?

typescript angular-cli angular angular6 angular-cli-v6

12
推荐指数
3
解决办法
6912
查看次数

无法在 Visual Studio Code 终端中执行 Angular CLI 命令

我无法Angular CLI在 Visual Studio Code 终端中执行命令。当我ng --version在终端中输入时,它正在打开 ng 文件而不是执行命令。

知道如何解决上述问题吗?

visual-studio-code angular-cli angular

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

棱角分明。从 html 标记中删除属性的构建步骤

我们在标记中使用“data-test”属性来查询测试中的元素。例如:

<div data-test='myDiv'></div>
Run Code Online (Sandbox Code Playgroud)

我们不希望此属性出现在生产版本中。到目前为止,我找到了一种解决方法来创建一个指令,该指令在运行时删除生产构建的属性。它肯定会花费一些 CPU 并且似乎值得怀疑。寻找一种在构建时删除属性的方法。欢迎任何想法。

html testing webpack angular-cli angular

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

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万
查看次数

如何将 PurgeCSS 与 Angular CLI 项目集成

我有一个使用 Angular CLI 创建的 Angular 项目,所以我有 angular.json 文件用于配置构建。

我想集成 PurgeCSS,因为它似乎是减少 CSS 包大小的好工具。

在PurgeCSS 网站上,他们解释了如何与 Webpack 集成。我找到了一个教程,解释了如何添加自定义 webpack 与 Angular CLI 的集成。

有没有人有 PurgeCSS 与 Angular CLI 项目集成的成功例子?

webpack angular-cli angular css-purge

12
推荐指数
3
解决办法
6623
查看次数