我有我的Angular 4网站运行良好,但它运行在〜/ app /文件夹中。所以它出现在http://example.com/app,但我只是希望它在http://example.com如何让我的角色网站在根目录中而不是在文件夹中呈现?
显示现在我有:
的package.json
ng build --base-href /app/
.angular-CLI。 json
"outDir": "./../app"
伟大的工程,但如果我更改这些来(这似乎是它的工作):
的package.json
ng build --base-href/
.angular-cli.json
"outDir": "./../"
它不会在根中呈现 - 我错过了什么?!谢谢!
编辑 这里是我的tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
而且我的src/tsconfig.app.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
我现在意识到,我可能希望它是在它自己的文件夹中,但是看起来它在根目录下,那也能正常工作!
您是否在html中使用'base'标签? –
尝试从您的html中删除基础href。将这个'{provide:APP_BASE_HREF,useValue:'/'}添加到你的app.module。 –
你也可以提供你的tsconfig文件吗? 'src/tsconfig.app.json'和'your_root/tsconfig.json' –