Skip to content

Commit 108bbfc

Browse files
author
laco0416
committed
feat(@angular/cli): add baseHref property to appConfig
1 parent ec28715 commit 108bbfc

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

packages/@angular/cli/lib/config/schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
"type": "string",
8080
"description": "URL where files will be deployed."
8181
},
82+
"baseHref": {
83+
"type": "string",
84+
"description": "Base url for the application being built."
85+
},
8286
"index": {
8387
"type": "string",
8488
"default": "index.html",

packages/@angular/cli/models/webpack-config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export class NgCliWebpackConfig {
9797
public mergeConfigs(buildOptions: BuildOptions, appConfig: any) {
9898
const mergeableOptions = {
9999
outputPath: appConfig.outDir,
100-
deployUrl: appConfig.deployUrl
100+
deployUrl: appConfig.deployUrl,
101+
baseHref: appConfig.baseHref
101102
};
102103

103104
return Object.assign({}, mergeableOptions, buildOptions);

tests/e2e/tests/build/base-href.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import {ng} from '../../utils/process';
22
import {expectFileToMatch} from '../../utils/fs';
3-
3+
import { updateJsonFile } from '../../utils/project';
44

55
export default function() {
66
return ng('build', '--base-href', '/myUrl')
7-
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
7+
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
8+
.then(() => updateJsonFile('.angular-cli.json', configJson => {
9+
const app = configJson['apps'][0];
10+
app['baseHref'] = '/myUrl';
11+
}))
12+
.then(() => ng('build'))
13+
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
814
}

0 commit comments

Comments
 (0)