Skip to content

Commit

Permalink
feat: add host flag support for ng serve (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLarkInn authored and filipesilva committed Jul 25, 2016
1 parent b8f502e commit 930785f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions addon/ng2/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = Command.extend({

availableOptions: [
{ name: 'port', type: Number, default: defaultPort, aliases: ['p'] },
{ name: 'host', type: String, aliases: ['H'], description: 'Listens on all interfaces by default' },
{ name: 'host', type: String, default: 'localhost', aliases: ['H'], description: 'Listens on all interfaces by default' },
{ name: 'proxy', type: String, aliases: ['pr', 'pxy'] },
{ name: 'insecure-proxy', type: Boolean, default: false, aliases: ['inspr'], description: 'Set false to proxy self-signed SSL certificates' },
{ name: 'watcher', type: String, default: 'events', aliases: ['w'] },
Expand All @@ -61,7 +61,7 @@ module.exports = Command.extend({
}
if (commandOptions.target === 'production') {
commandOptions.environment = 'prod';
}
}
}

commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host;
Expand Down
8 changes: 4 additions & 4 deletions addon/ng2/tasks/serve-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { CliConfig } from '../models/config';

module.exports = Task.extend({
run: function(commandOptions: ServeTaskOptions) {

let lastHash = null;
let webpackCompiler: any;

var config: NgCliWebpackConfig = new NgCliWebpackConfig(this.project, commandOptions.target, commandOptions.environment).config;
// This allows for live reload of page when changes are made to repo.
// https://webpack.github.io/docs/webpack-dev-server.html#inline-mode
config.entry.main.unshift(`webpack-dev-server/client?http://localhost:${commandOptions.port}/`);
config.entry.main.unshift(`webpack-dev-server/client?http://${commandOptions.host}:${commandOptions.port}/`);
webpackCompiler = webpack(config);

webpackCompiler.apply(new ProgressPlugin({
Expand All @@ -33,11 +33,11 @@ module.exports = Task.extend({
inline: true
};

const serveMessage:string = chalk.green(`\n*\n*\n NG Live Development Server is running on http://localhost:${commandOptions.port}.\n*\n*`);
const serveMessage:string = chalk.green(`\n*\n*\n NG Live Development Server is running on http://${commandOptions.host}:${commandOptions.port}.\n*\n*`);
const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);

return new Promise((resolve, reject) => {
server.listen(commandOptions.port, 'localhost', function(err, stats) {
server.listen(commandOptions.port, `${commandOptions.host}`, function(err, stats) {
if(err) {
lastHash = null;
console.error(err.stack || err);
Expand Down

0 comments on commit 930785f

Please sign in to comment.