mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-25 08:41:39 +08:00
feat(@angular/cli): add baseHref property to appConfig
This commit is contained in:
parent
01cbf65728
commit
692b378770
@ -79,6 +79,10 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "URL where files will be deployed."
|
"description": "URL where files will be deployed."
|
||||||
},
|
},
|
||||||
|
"baseHref": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Base url for the application being built."
|
||||||
|
},
|
||||||
"index": {
|
"index": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "index.html",
|
"default": "index.html",
|
||||||
|
@ -97,7 +97,8 @@ export class NgCliWebpackConfig {
|
|||||||
public mergeConfigs(buildOptions: BuildOptions, appConfig: any) {
|
public mergeConfigs(buildOptions: BuildOptions, appConfig: any) {
|
||||||
const mergeableOptions = {
|
const mergeableOptions = {
|
||||||
outputPath: appConfig.outDir,
|
outputPath: appConfig.outDir,
|
||||||
deployUrl: appConfig.deployUrl
|
deployUrl: appConfig.deployUrl,
|
||||||
|
baseHref: appConfig.baseHref
|
||||||
};
|
};
|
||||||
|
|
||||||
return Object.assign({}, mergeableOptions, buildOptions);
|
return Object.assign({}, mergeableOptions, buildOptions);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {ng} from '../../utils/process';
|
import {ng} from '../../utils/process';
|
||||||
import {expectFileToMatch} from '../../utils/fs';
|
import {expectFileToMatch} from '../../utils/fs';
|
||||||
import {getGlobalVariable} from '../../utils/env';
|
import {getGlobalVariable} from '../../utils/env';
|
||||||
|
import {updateJsonFile} from '../../utils/project';
|
||||||
|
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
@ -10,5 +11,11 @@ export default function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ng('build', '--base-href', '/myUrl')
|
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">/))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user