@@ -11,6 +11,23 @@ PortFinder.basePort = 49152;
11
11
const getPort = Promise . denodeify ( PortFinder . getPort ) ;
12
12
const defaultPort = process . env . PORT || 4200 ;
13
13
14
+ export interface IServeTaskOptions {
15
+ port ?: number ;
16
+ host ?: string ;
17
+ proxy ?: string ;
18
+ insecureProxy ?: boolean ;
19
+ watcher ?: string ;
20
+ liveReload ?: boolean ;
21
+ liveReloadHost ?: string ;
22
+ liveReloadPort ?: number ;
23
+ liveReloadBaseUrl ?: string ;
24
+ liveReloadLiveCss ?: boolean ;
25
+ environment ?: string ;
26
+ outputPath ?: string ;
27
+ ssl ?: boolean ;
28
+ sslKey ?: string ;
29
+ sslCert ?: string ;
30
+ }
14
31
15
32
module . exports = Command . extend ( {
16
33
name : 'serve' ,
@@ -35,12 +52,12 @@ module.exports = Command.extend({
35
52
{ name : 'ssl-cert' , type : String , default : 'ssl/server.crt' }
36
53
] ,
37
54
38
- run : function ( commandOptions ) {
55
+ run : function ( commandOptions : IServeTaskOptions ) {
39
56
commandOptions . liveReloadHost = commandOptions . liveReloadHost || commandOptions . host ;
40
57
41
58
return this . _checkExpressPort ( commandOptions )
42
59
. then ( this . _autoFindLiveReloadPort . bind ( this ) )
43
- . then ( function ( commandOptions ) {
60
+ . then ( function ( commandOptions : IServeTaskOptions ) {
44
61
commandOptions = assign ( { } , commandOptions , {
45
62
baseURL : this . project . config ( commandOptions . environment ) . baseURL || '/'
46
63
} ) ;
@@ -53,11 +70,13 @@ module.exports = Command.extend({
53
70
}
54
71
}
55
72
56
- var ServeTask = require ( '../tasks/serve' ) ;
57
- var serve = new ServeTask ( {
73
+ const ServeWebpackTask = ( require ( '../tasks/serve-webpack.ts' ) )
74
+ // var ServeTask = require('../tasks/serve');
75
+
76
+ var serve = new ServeWebpackTask ( {
58
77
ui : this . ui ,
59
78
analytics : this . analytics ,
60
- project : this . project
79
+ project : this . project ,
61
80
} ) ;
62
81
63
82
return win . checkWindowsElevation ( this . ui ) . then ( function ( ) {
@@ -66,9 +85,9 @@ module.exports = Command.extend({
66
85
} . bind ( this ) ) ;
67
86
} ,
68
87
69
- _checkExpressPort : function ( commandOptions ) {
88
+ _checkExpressPort : function ( commandOptions : IServeTaskOptions ) {
70
89
return getPort ( { port : commandOptions . port , host : commandOptions . host } )
71
- . then ( function ( foundPort ) {
90
+ . then ( function ( foundPort : number ) {
72
91
73
92
if ( commandOptions . port !== foundPort && commandOptions . port !== 0 ) {
74
93
var message = 'Port ' + commandOptions . port + ' is already in use.' ;
@@ -82,9 +101,9 @@ module.exports = Command.extend({
82
101
} . bind ( this ) ) ;
83
102
} ,
84
103
85
- _autoFindLiveReloadPort : function ( commandOptions ) {
104
+ _autoFindLiveReloadPort : function ( commandOptions : IServeTaskOptions ) {
86
105
return getPort ( { port : commandOptions . liveReloadPort , host : commandOptions . liveReloadHost } )
87
- . then ( function ( foundPort ) {
106
+ . then ( function ( foundPort : number ) {
88
107
89
108
// if live reload port matches express port, try one higher
90
109
if ( foundPort === commandOptions . port ) {
0 commit comments