Angular CLI没有应对图像和字体目录

时间:2017-11-02 14:49:52

标签: angular angular-cli

我在设置 angular-cli.json 时无法从 fonts 和 images 目录> node_modules 中的@cmsgov 目录。

我在终端中遇到的许多错误之一是[/Users/user/WebstormProjects/angular-app/src/images/warning.svg] warning.svg不存在。如果需要,我可以提供更多的错误代码。

通过查看 angular-cli 的文档,我应该可以使用以下代码行复制文件:{ "glob": "**/*", "input": "../node_modules/some-package/images", "output": "./some-package/" },但是当我尝试这样做时,我会一直收到错误。我不确定我做错了什么。

我目前正在使用angular-cli版本 1.4.9 ,如果需要,我可以提供完整的 package.json

这是我的 angular-cli.json 文件:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "angular-app"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico",
        { "glob": "**/*", "input": "../node_modules/@cmsgov/design-system-core/fonts", "output": "./assets/fonts" },
        { "glob": "**/*", "input": "../node_modules/@cmsgov/design-system-core/images", "output": "./assets/images" },
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "sass/styles.scss"
      ],
      "stylePreprocessorOptions": {
        "includePaths": [
          "../node_modules/"
        ]
      },
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "scss",
    "component": {
    }
  }
}

1 个答案:

答案 0 :(得分:1)

看起来您的资产正在正确复制。要引用这些文件,您应该使用路径assets/images/warning.svg