@@ -28,7 +28,7 @@ import clearTerminal from '../utilities/clear'
28
28
import readConfig_ from '../utilities/read-config'
29
29
30
30
command (
31
- 'serve [port][prod][aot][ sw]' ,
31
+ 'serve [port][prod][sw]' ,
32
32
'serve your application' ,
33
33
args => {
34
34
return args
@@ -54,7 +54,11 @@ function logServeCommandStart() {
54
54
logInfo ( 'Launching Serve Command' )
55
55
}
56
56
57
- function serve ( isProdBuild = false , isServiceWorkerEnabled = false ) {
57
+ export function serve (
58
+ isProdBuild = false ,
59
+ isServiceWorkerEnabled = false ,
60
+ buildOnly = false
61
+ ) {
58
62
readConfig_ ( )
59
63
. pipe (
60
64
tap ( logServeCommandStart ) ,
@@ -175,52 +179,56 @@ function serve(isProdBuild = false, isServiceWorkerEnabled = false) {
175
179
} )
176
180
fuseSw . bundle ( 'ngsw-worker' ) . instructions ( ' > [ngsw-worker.js]' )
177
181
178
- fuseBrowser
179
- . bundle ( 'vendor' )
180
- . watch ( watchDir )
181
- . instructions ( ` ~ ${ browserModule } ` )
182
- . completed ( fn => {
183
- isServiceWorkerEnabled &&
184
- execSync (
185
- `node_modules/.bin/ngsw-config .dist/public src/app/ngsw.json`
186
- )
187
- fuseServer
188
- . bundle ( 'server' )
189
- . instructions ( ` > [${ config . fusebox . server . serverModule } ]` )
190
- . completed ( proc => {
191
- prevServerProcess && prevServerProcess . kill ( )
192
- clearTerminal ( )
193
- proc . start ( )
194
- prevServerProcess = proc
195
- } )
196
- fuseServer . run ( )
197
- } )
182
+ // tslint:disable:no-if-statement
183
+ const vendor = fuseBrowser . bundle ( 'vendor' )
184
+ if ( ! buildOnly ) vendor . watch ( watchDir )
185
+ vendor . instructions ( ` ~ ${ browserModule } ` ) . completed ( fn => {
186
+ isServiceWorkerEnabled &&
187
+ execSync (
188
+ `node_modules/.bin/ngsw-config .dist/public src/app/ngsw.json`
189
+ )
190
+ const serverBundle = fuseServer
191
+ . bundle ( 'server' )
192
+ . instructions ( ` > [${ config . fusebox . server . serverModule } ]` )
198
193
199
- fuseBrowser
200
- . bundle ( 'app' )
201
- . watch ( watchDir )
194
+ if ( ! buildOnly ) {
195
+ serverBundle . completed ( proc => {
196
+ prevServerProcess && prevServerProcess . kill ( )
197
+ clearTerminal ( )
198
+ proc . start ( )
199
+ prevServerProcess = proc
200
+ } )
201
+ }
202
+ fuseServer . run ( )
203
+ } )
204
+
205
+ const appBundle = fuseBrowser . bundle ( 'app' )
206
+ if ( ! buildOnly ) appBundle . watch ( watchDir )
207
+ appBundle
202
208
. instructions ( ` !> [${ browserModule } ]` )
203
209
. splitConfig ( { dest : '../js/modules' } )
204
210
205
211
logInfo ( 'Bundling your application, this may take some time...' )
206
212
207
213
renderSassDir ( )
208
214
209
- const sass = exec (
210
- 'node_modules/.bin/node-sass --watch src/**/*.scss --output-style compressed --output src/**'
211
- )
212
- sass . on ( 'error' , err => {
213
- console . log ( err )
214
- process . exit ( 1 )
215
- } )
216
- sass . on ( 'message' , err => {
217
- console . error ( err )
218
- process . exit ( 1 )
219
- } )
220
- sass . stderr . on ( 'data' , err => {
221
- console . log ( err )
222
- process . exit ( 1 )
223
- } )
215
+ if ( ! buildOnly ) {
216
+ const sass = exec (
217
+ 'node_modules/.bin/node-sass --watch src/**/*.scss --output-style compressed --output src/**'
218
+ )
219
+ sass . on ( 'error' , err => {
220
+ console . log ( err )
221
+ process . exit ( 1 )
222
+ } )
223
+ sass . on ( 'message' , err => {
224
+ console . error ( err )
225
+ process . exit ( 1 )
226
+ } )
227
+ sass . stderr . on ( 'data' , err => {
228
+ console . log ( err )
229
+ process . exit ( 1 )
230
+ } )
231
+ }
224
232
225
233
copy ( resolve ( 'src/assets' ) , resolve ( '.dist/public/assets' ) )
226
234
. then ( ( ) => fuseSw . run ( ) )
0 commit comments