Skip to content

feat(@angular/cli): add baseHref property to appConfig #6461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">/))
}