Skip to content

Commit c5ba235

Browse files
committed
Feature: Allow content to be served from virtual host path e.g. http://example.com/admin/
1 parent c2dd94c commit c5ba235

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

packages/angular-cli/commands/serve.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface ServeTaskOptions {
2727
sslCert?: string;
2828
aot?: boolean;
2929
open?: boolean;
30+
path?: string;
3031
}
3132

3233
const ServeCommand = Command.extend({
@@ -88,6 +89,12 @@ const ServeCommand = Command.extend({
8889
aliases: ['o'],
8990
description: 'Opens the url in default browser',
9091
},
92+
{
93+
name: 'path',
94+
type: String,
95+
default: '/',
96+
description: 'makes the content available on path e.g. http://host:port/path'
97+
},
9198
],
9299

93100
run: function(commandOptions: ServeTaskOptions) {

packages/angular-cli/custom-typings.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interface IWebpackDevServerConfigurationOptions {
22
contentBase?: string;
33
hot?: boolean;
4-
historyApiFallback?: boolean;
4+
historyApiFallback?: boolean | {[key:string]: string};
55
compress?: boolean;
66
proxy?: {[key: string]: string};
77
staticOptions?: any;

packages/angular-cli/tasks/serve-webpack.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ export default Task.extend({
5757
this.project.root,
5858
`./${CliConfig.fromProject().config.apps[0].root}`
5959
),
60-
historyApiFallback: true,
60+
historyApiFallback: {
61+
index: commandOptions.path
62+
},
6163
stats: webpackDevServerOutputOptions,
6264
inline: true,
6365
proxy: proxyConfig,
6466
watchOptions: {
6567
poll: CliConfig.fromProject().config.defaults.poll
66-
}
68+
},
69+
publicPath: commandOptions.path,
6770
};
6871

6972
ui.writeLine(chalk.green(oneLine`

0 commit comments

Comments
 (0)