1
1
import { task , watch } from 'gulp' ;
2
- import { DIST_ROOT , SOURCE_ROOT } from '../constants' ;
2
+ import { DIST_ROOT , SOURCE_ROOT , PROJECT_ROOT , DIST_BUNDLES , DIST_MATERIAL } from '../constants' ;
3
3
import {
4
4
sassBuildTask , tsBuildTask , copyTask , buildAppTask , sequenceTask , triggerLivereload ,
5
5
serverTask
6
6
} from '../util/task_helpers' ;
7
7
import { join } from 'path' ;
8
+ import { copyFiles } from '../util/copy-files' ;
9
+
10
+ // These imports don't have any typings provided.
11
+ const firebaseTools = require ( 'firebase-tools' ) ;
8
12
9
13
const appDir = join ( SOURCE_ROOT , 'demo-app' ) ;
10
14
const outDir = join ( DIST_ROOT , 'packages' , 'demo-app' ) ;
11
15
16
+ /** Array of vendors that are required to serve the demo-app. */
17
+ const appVendors = [
18
+ '@angular' , 'systemjs' , 'zone.js' , 'rxjs' , 'hammerjs' , 'core-js' , 'web-animations-js'
19
+ ] ;
20
+
21
+ /** Glob that matches all required vendors for the demo-app. */
22
+ const vendorGlob = `+(${ appVendors . join ( '|' ) } )/**/*.+(html|css|js|map)` ;
23
+
12
24
task ( ':watch:devapp' , ( ) => {
13
25
watch ( join ( appDir , '**/*.ts' ) , [ ':build:devapp:ts' , triggerLivereload ] ) ;
14
26
watch ( join ( appDir , '**/*.scss' ) , [ ':build:devapp:scss' , triggerLivereload ] ) ;
@@ -28,3 +40,21 @@ task(':serve:devapp', serverTask(outDir, true));
28
40
task ( 'serve:devapp' , [ 'build:devapp' ] , sequenceTask (
29
41
[ ':serve:devapp' , 'material:watch' , ':watch:devapp' ]
30
42
) ) ;
43
+
44
+ /** Task that copies all vendors into the demo-app package. Allows hosting the app on firebase. */
45
+ task ( 'stage-deploy:devapp' , [ 'build:devapp' ] , ( ) => {
46
+ copyFiles ( join ( PROJECT_ROOT , 'node_modules' ) , vendorGlob , join ( outDir , 'node_modules' ) ) ;
47
+ copyFiles ( DIST_BUNDLES , '*.+(js|map)' , join ( outDir , 'dist/bundles' ) ) ;
48
+ copyFiles ( DIST_MATERIAL , '**/prebuilt/*.+(css|map)' , join ( outDir , 'dist/packages/material' ) ) ;
49
+ } ) ;
50
+
51
+ /**
52
+ * Task that deploys the demo-app to Firebase. Firebase project will be the one that is
53
+ * set for project directory using the Firebase CLI.
54
+ */
55
+ task ( 'deploy:devapp' , [ 'stage-deploy:devapp' ] , ( ) => {
56
+ return firebaseTools . deploy ( { cwd : PROJECT_ROOT , only : 'hosting' } )
57
+ // Firebase tools opens a persistent websocket connection and the process will never exit.
58
+ . then ( ( ) => { console . log ( 'Successfully deployed the demo-app to firebase' ) ; process . exit ( 0 ) ; } )
59
+ . catch ( ( err : any ) => { console . log ( err ) ; process . exit ( 1 ) ; } ) ;
60
+ } ) ;
0 commit comments