tsconfig.json的 "baseUrl": "./",同一级加配置ts别名路径
... // 全局ts路径别名 "paths": { "@app/*": ["src/app/*"], "@assets/*": ["src/assets/*"], "@env/*": ["src/environments/*"], }, ...
angular.json>projects>...>architect>build>options>加入配置css别名路径
... "stylePreprocessorOptions": { "includePaths": ["src/assets/css"] }, ...
引用的代码
引用ts
import { SgService } from '@app/common/sg.service'; 引用scss @import 'sg'; @import 'sg1';