@@ -31,7 +31,15 @@ export default Task.extend({
31
31
if ( projectConfig . project && projectConfig . project . ejected ) {
32
32
throw new SilentError ( 'An ejected project cannot use the build command anymore.' ) ;
33
33
}
34
- rimraf . sync ( path . resolve ( this . project . root , outputPath ) ) ;
34
+
35
+ const contentBase = path . resolve ( this . project . root , outputPath ) ;
36
+ if ( serveTaskOptions . useDist ) {
37
+ if ( ! fs . existsSync ( contentBase ) ) {
38
+ throw new SilentError ( 'Dist directory not found' ) ;
39
+ }
40
+ } else {
41
+ rimraf . sync ( contentBase ) ;
42
+ }
35
43
36
44
const serveDefaults = {
37
45
// default deployUrl to '' on serve to prevent the default from .angular-cli.json
@@ -151,6 +159,12 @@ export default Task.extend({
151
159
overlay : serveTaskOptions . target === 'development'
152
160
} ;
153
161
162
+ if ( serveTaskOptions . useDist ) {
163
+ webpackDevServerConfiguration . contentBase = contentBase ;
164
+ webpackDevServerConfiguration . lazy = true ;
165
+ webpackDevServerConfiguration . filename = appConfig . main ;
166
+ }
167
+
154
168
if ( sslKey != null && sslCert != null ) {
155
169
webpackDevServerConfiguration . key = sslKey ;
156
170
webpackDevServerConfiguration . cert = sslCert ;
@@ -182,7 +196,10 @@ export default Task.extend({
182
196
return reject ( err ) ;
183
197
}
184
198
if ( serveTaskOptions . open ) {
185
- opn ( serverAddress ) ;
199
+ opn ( serverAddress ) ;
200
+ }
201
+ if ( serveTaskOptions . useDist && rebuildDoneCb ) {
202
+ rebuildDoneCb ( ) ;
186
203
}
187
204
} ) ;
188
205
} )
0 commit comments