在Angular中,因为将webpack打包内置了,所以设置webpack的alias需要按照如下方式
别名设置
// tsconfig.json文件中增加如下配置
"paths": {
"@shared": [ "app/shared" ],
"@shared/*": [ "app/shared/*" ],
"@app": [ "app" ],
"@app/*": [ "app/*" ]
}
别名使用
import test from '@app/test'
在Angular中,因为将webpack打包内置了,所以设置webpack的alias需要按照如下方式
// tsconfig.json文件中增加如下配置
"paths": {
"@shared": [ "app/shared" ],
"@shared/*": [ "app/shared/*" ],
"@app": [ "app" ],
"@app/*": [ "app/*" ]
}
import test from '@app/test'