版本
Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.0
@angular-devkit/build-angular 0.6.0
@angular-devkit/build-optimizer 0.6.0
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.0
@angular/cdk 6.0.1
@angular/flex-layout 6.0.0-beta.15
@angular/material 6.0.1
@ngtools/webpack 6.0.0
@schematics/angular 0.6.0
@schematics/update 0.6.0
rxjs 6.1.0
typescript 2.7.2
webpack 4.6.0
步骤
Install Angular v6 / CLI v6
ng build --configuration=stage --bh /XYZ/
错误 未知选项:' - bh'
观察到的行为 build -bh CLI选项在v6中不起作用(或已被删除?),但documentation尚未更新,以反映使用' base-href&#39构建的新方法;
答案 0 :(得分:12)
您是否尝试使用完整选项名称?
ng build --configuration=stage --base-href /XYZ/
我正在使用角度6,这仍然有效。但是我不确定它是否仍然适用于未来(参见github issue)
如果上述方法不起作用,您可以在baseHref
文件的configurations
部分指定angular.json
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
},
"configurations": {
"stage": {
"optimization": true,
"baseHref": "/XYZ/", //<=== here