数据路径“”不应具有其他属性(src /资产)

时间:2019-04-01 13:16:59

标签: angular ionic-framework ionic-cli

我正在尝试在新的离子项目(离子4)中添加CSS,但是我得到了

Data path "" should NOT have additional properties(src/assets)

我尚未进行cli / ionic / angular的任何迁移,但仍然收到此错误。我确定我有正确的angular.json文件。

        {
          "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
      "version": 1,
      "defaultProject": "app",
      "newProjectRoot": "projects",
      "projects": {
        "app": {
          "root": "",
          "sourceRoot": "src",


  "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "www",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "src/assets": [
              {
                "glob": "**/*",
                "input": "src/src/assets",
                "output": "src/assets"
              },
              {
                "glob": "**/*.svg",
                "input": "node_modules/ionicons/dist/ionicons/svg",
                "output": "./svg"
              }
            ],
            "styles": [
              {
                "input": "src/theme/variables.scss"
              },
              {
                "input": "src/global.scss"
              },
              {
                "input": "src/Footer-Basic.scss"
              }
            ],
            "scripts": [],
            "es5BrowserSupport": true
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                }
              ]
            },
            "ci": {
              "progress": false
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            },
            "ci": {
              "progress": false
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [],
            "scripts": [],
            "src/assets": [
              {
                "glob": "favicon.ico",
                "input": "src/",
                "output": "/"
              },
              {
                "glob": "**/*",
                "input": "src/src/assets",
                "output": "/src/assets"
              }
            ]
          },
          "configurations": {
            "ci": {
              "progress": false,
              "watch": false
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
            "exclude": ["**/node_modules/**"]
          }
        },
        "ionic-cordova-build": {
          "builder": "@ionic/angular-toolkit:cordova-build",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            }
          }
        },
        "ionic-cordova-serve": {
          "builder": "@ionic/angular-toolkit:cordova-serve",
          "options": {
            "cordovaBuildTarget": "app:ionic-cordova-build",
            "devServerTarget": "app:serve"
          },
          "configurations": {
            "production": {
              "cordovaBuildTarget": "app:ionic-cordova-build:production",
              "devServerTarget": "app:serve:production"
            }
          }
        }
      }
    },
    "app-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "app:serve"
          },
          "configurations": {
            "ci": {
              "devServerTarget": "app:serve:ci"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": ["**/node_modules/**"]
          }
        }
      }
    }
  },
  "cli": {
    "defaultCollection": "@ionic/angular-toolkit"
  },
  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss"
    }
  }
}

我刚刚在样式部分添加了另一个条目。但是它不起作用。 帮助找出问题所在。按要求添加了整个json文件。

2 个答案:

答案 0 :(得分:1)

Please add all css files into app.scss file(it is my project css sample i have mentioned)

@import url('../assets/css/sb-admin.css');
@import url('../assets/css/style.css');
@import url('../assets/css/theme.css');
@import url('../assets/css/bootstrap-slider.css');
@import '../../node_modules/angular-calendar/css/angular-calendar.css';

C:\Project\src\styles\app.scss


Please add app css file into angular.json
     "styles": ["src/styles/app.scss"],

“样式”:[“ src / styles / style.scss”,“ src / styles / theme.scss”]

添加与上述在Anuglar.json文件中提到的相同的内容

答案 1 :(得分:0)

模式验证可以准确地告诉您不允许使用哪些属性(“ src / assets”)。您需要删除它们才能使构建正常工作。

也许您找到并替换了它,并且无意中将其重命名了?我相信您打算使用键“资产”。