В вашем tsconfig.json
вы можете создавать собственные псевдонимы для ваших путей.
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"paths": { <=========== ADD PATHS
"@assets/*": [
"assets/images/*"
]
}, <=========== END OF PATHS
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"allowSyntheticDefaultImports": true,
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
Другой вариант в вашем angular.json
добавить следующую строку:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"pgp-front": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/pgp-front",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/assets/images/favicon.ico",
"src/assets", <================== ADD THIS LINE
"src/manifest.webmanifest"
],
"styles": [ File continues...
Затем используйте это так:
![enter image description here](https://i.stack.imgur.com/h47Ao.png)