Skip to content

Commit

Permalink
feat(@angular/cli): add baseHref property to appConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
laco0416 authored and Brocco committed Jun 12, 2017
1 parent 01cbf65 commit 692b378
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/@angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"type": "string",
"description": "URL where files will be deployed."
},
"baseHref": {
"type": "string",
"description": "Base url for the application being built."
},
"index": {
"type": "string",
"default": "index.html",
Expand Down
3 changes: 2 additions & 1 deletion packages/@angular/cli/models/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export class NgCliWebpackConfig {
public mergeConfigs(buildOptions: BuildOptions, appConfig: any) {
const mergeableOptions = {
outputPath: appConfig.outDir,
deployUrl: appConfig.deployUrl
deployUrl: appConfig.deployUrl,
baseHref: appConfig.baseHref
};

return Object.assign({}, mergeableOptions, buildOptions);
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/tests/build/base-href.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ng} from '../../utils/process';
import {expectFileToMatch} from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';
import {updateJsonFile} from '../../utils/project';


export default function() {
Expand All @@ -10,5 +11,11 @@ export default function() {
}

return ng('build', '--base-href', '/myUrl')
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['baseHref'] = '/myUrl';
}))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
}

0 comments on commit 692b378

Please sign in to comment.