Я пытаюсь создать навигационную панель с угловым материалом.Итак, я начну с нескольких установок:
1) Я установил угловые материалы с помощью npm 2) Я настроил их в style.css, как показано ниже:
/* You can add global styles to this file, and also import other style files */
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
@import '~https://fonts.googleapis.com/icon?family=Material+Icons';
3) Я связал темы угловых материалов сindex.html как показано ниже:
<link href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
Для получения дополнительной информации о моем окружении взгляните на мой файл angular.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"admin-portal": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"targets": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/admin-portal",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"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
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "admin-portal:build"
},
"configurations": {
"production": {
"browserTarget": "admin-portal:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "admin-portal: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": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"admin-portal-e2e": {
"root": "e2e/",
"projectType": "application",
"targets": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "admin-portal:serve"
},
"configurations": {
"production": {
"devServerTarget": "admin-portal:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "admin-portal"
}
Но когда я запускаю ng serve, я получаю эту ошибкукак упомянуто ниже:
ERROR in ./src/styles.css (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./src/styles.css)
Module build failed (from ./node_modules/postcss-loader/lib/index.js):
Error: Can't resolve 'https://fonts.googleapis.com/icon?family=Material+Icons' in
'C: \ Angular Projects \ admin-portal \ src' в doResolve (C: \ Angular Projects \ admin-portal \ node_modules \ extended-resol \ \ lib \Resolver.js: 180: 19) в hook.callAsync (C: \ Angular Projects \ admin-portal \ node_modules \ extended-resol \ \ lib \ Resolver.js: 238: 5) в _fn0 (при создании (C: \ Angular)Проекты \ admin-portal \ node_modules \ tapable \ lib \ HookCodeFactory.js: 32: 10),: 15: 1) в resolver.doResolve (C: \ Angular Projects \ admin-portal \ node_modules \ Улучшенное разрешение \ lib \ UnsafeCachePlugin.js: 37: 5) в hook.callAsync (C: \ Angular Projects \ admin-portal \ node_modules \ extended-resol \ \ lib \ Resolver.js: 238: 5) в _fn0 (eval при создании (C: \ Angular Projects \ admin-portal \ node_modules \ tapable \ lib \ HookCodeFactory.js: 32: 10),: 15: 1) в hook.callAsync (C: \ Angular Projects \ admin-portal\ node_modules \ extended-resolve \ lib \ Resolver.js: 238: 5) в _fn0 (проверка при создании (C: \ Angular Projects \ admin-portal \ node_modules \ tapable \ lib \ HookCodeFactory.js: 32: 10),:12: 1) в resolver.doResolve (C: \ Angular Projects \ admin-portal \ node_modules \ advanced-resol \ lib \ DescriptionFilePlugin.js: 42: 38) на hook.callAsync (C: \ Angular Projects \ admin-portal \node_modules \ extended-resolve \ lib \ Resolver.js: 238: 5) в _fn5 (проверка при создании (C: \ Angular Projects \ admin-portal \ node_modules \ tapable \ lib \ HookCodeFactory.js: 32: 10),: 57: 1) в resolver.doResolve (C: \ Angular Projects \ admin-portal \ node_modules \ extended-resol \ \ lib \ ModuleKindPlugin.js: 23: 37) на hook.callAsync (C: \ Angular Projects \ admin-portal \ node_modules)\ Расширенное разрешение \ lib \ Resolver.js: 238: 5) в _fn0 (eval при создании (C: \ Angular Projects \ admin-portal \ node_modules \ tapable \ lib \ HookCodeFactory.j)s: 32: 10),: 15: 1) в hook.callAsync (C: \ Angular Projects \ admin-portal \ node_modules \ extended-resolve \ lib \ Resolver.js: 238: 5) в _fn1 (eval при создании (C: \ Angular Projects \ admin-portal \ node_modules \ tapable \ lib \ HookCodeFactory.js: 32: 10),: 24: 1)