Skip to content

fix(@angular/cli): serve --live-reload option #4626

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions docs/documentation/serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

`--proxy-config` (`-pc`) proxy configuration file

`--watch` (`-w`) flag to turn off watch mode

`--live-reload` (`-lr`) flag to turn off live reloading

`--live-reload-host` (`-lrh`) specify the host for live reloading
Expand Down
10 changes: 9 additions & 1 deletion packages/@angular/cli/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const defaultPort = process.env.PORT || config.get('defaults.serve.port');
const defaultHost = config.get('defaults.serve.host');

export interface ServeTaskOptions extends BuildOptions {
watch?: boolean;
port?: number;
host?: string;
proxyConfig?: string;
Expand All @@ -43,6 +44,7 @@ export const baseServeCommandOptions: any = baseBuildCommandOptions.concat([
description: `Listens only on ${defaultHost} by default`
},
{ name: 'proxy-config', type: 'Path', aliases: ['pc'] },
{ name: 'watch', type: Boolean, default: true, aliases: ['w'] },
{ name: 'ssl', type: Boolean, default: false },
{ name: 'ssl-key', type: String, default: 'ssl/server.key' },
{ name: 'ssl-cert', type: String, default: 'ssl/server.crt' },
Expand All @@ -61,7 +63,12 @@ const ServeCommand = Command.extend({
aliases: ['server', 's'],

availableOptions: baseServeCommandOptions.concat([
{ name: 'live-reload', type: Boolean, default: true, aliases: ['lr'] },
{
name: 'live-reload',
type: Boolean,
aliases: ['lr'],
description: 'Defaults to watch'
},
{
name: 'live-reload-host',
type: String,
Expand Down Expand Up @@ -99,6 +106,7 @@ const ServeCommand = Command.extend({

Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host;
commandOptions.liveReload = commandOptions.liveReload || commandOptions.watch;

return checkExpressPort(commandOptions)
.then(() => autoFindLiveReloadPort(commandOptions))
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/custom-typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface IWebpackDevServerConfigurationOptions {
noInfo?: boolean;
lazy?: boolean;
filename?: string;
watch?: boolean;
watchOptions?: {
aggregateTimeout?: number;
poll?: number;
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/tasks/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default Task.extend({
inline: true,
proxy: proxyConfig,
compress: serveTaskOptions.target === 'production',
watch: serveTaskOptions.liveReload,
watchOptions: {
poll: projectConfig.defaults && projectConfig.defaults.poll
},
Expand Down