1
1
import { task , watch } from 'gulp' ;
2
- import * as path from 'path' ;
3
-
4
- import { SOURCE_ROOT , DIST_E2EAPP , PROJECT_ROOT } from '../build-config' ;
5
- import {
6
- tsBuildTask , copyTask , buildAppTask , execNodeTask , sequenceTask , serverTask
7
- } from '../util/task_helpers' ;
2
+ import { join } from 'path' ;
3
+ import { SOURCE_ROOT , DIST_E2EAPP , PROJECT_ROOT , DIST_RELEASES } from '../build-config' ;
4
+ import { ngcBuildTask , copyTask , execNodeTask , sequenceTask , serverTask } from '../util/task_helpers' ;
5
+ import { copySync } from 'fs-extra' ;
8
6
9
7
// There are no type definitions available for these imports.
10
8
const gulpConnect = require ( 'gulp-connect' ) ;
11
9
12
- const appDir = path . join ( SOURCE_ROOT , 'e2e-app' ) ;
10
+ const appDir = join ( SOURCE_ROOT , 'e2e-app' ) ;
13
11
const outDir = DIST_E2EAPP ;
14
12
15
- const PROTRACTOR_CONFIG_PATH = path . join ( PROJECT_ROOT , 'test/protractor.conf.js' ) ;
16
- const tsconfigPath = path . join ( appDir , 'tsconfig-build.json' ) ;
13
+ const PROTRACTOR_CONFIG_PATH = join ( PROJECT_ROOT , 'test/protractor.conf.js' ) ;
14
+ const tsconfigPath = join ( outDir , 'tsconfig-build.json' ) ;
17
15
18
- task ( ':watch:e2eapp' , ( ) => {
19
- watch ( path . join ( appDir , '**/*.ts' ) , [ ':build:e2eapp:ts' ] ) ;
20
- watch ( path . join ( appDir , '**/*.html' ) , [ ':build:e2eapp:assets' ] ) ;
21
- } ) ;
16
+ /** Glob that matches all files that need to be copied to the output folder. */
17
+ const assetsGlob = join ( appDir , '**/*.+(html|css|json|ts)' ) ;
18
+
19
+ /**
20
+ * Builds and serves the e2e-app and runs protractor once the e2e-app is ready.
21
+ */
22
+ task ( 'e2e' , sequenceTask (
23
+ [ ':test:protractor:setup' , 'serve:e2eapp' ] ,
24
+ ':test:protractor' ,
25
+ ':serve:e2eapp:stop' ,
26
+ 'screenshots' ,
27
+ ) ) ;
22
28
23
- /** Builds e2e app ts to js. */
24
- task ( ':build:e2eapp:ts' , tsBuildTask ( tsconfigPath ) ) ;
29
+ /** Task that builds the e2e-app in AOT mode. */
30
+ task ( 'e2e-app:build' , sequenceTask (
31
+ 'clean' ,
32
+ [ 'material:build-release' , 'cdk:build-release' ] ,
33
+ [ 'e2e-app:copy-release' , 'e2e-app:copy-assets' ] ,
34
+ 'e2e-app:build-ts'
35
+ ) ) ;
25
36
26
- /** Copies e2e app assets (html, css) to build output. */
27
- task ( ':build:e2eapp: assets' , copyTask ( appDir , outDir ) ) ;
37
+ /** Task that copies all required assets to the output folder . */
38
+ task ( 'e2e-app:copy- assets' , copyTask ( assetsGlob , outDir ) ) ;
28
39
29
- /** Builds the entire e2e app. */
30
- task ( 'build:e2eapp' , buildAppTask ( 'e2eapp' ) ) ;
40
+ /** Task that builds the TypeScript sources. Those are compiled inside of the dist folder. */
41
+ task ( 'e2e-app:build-ts' , ngcBuildTask ( tsconfigPath ) ) ;
42
+
43
+ task ( ':watch:e2eapp' , ( ) => {
44
+ watch ( join ( appDir , '**/*.ts' ) , [ 'e2e-app:build' ] ) ;
45
+ watch ( join ( appDir , '**/*.html' ) , [ 'e2e-app:copy-assets' ] ) ;
46
+ } ) ;
31
47
32
48
/** Ensures that protractor and webdriver are set up to run. */
33
49
task ( ':test:protractor:setup' , execNodeTask ( 'protractor' , 'webdriver-manager' , [ 'update' ] ) ) ;
@@ -42,21 +58,18 @@ task(':serve:e2eapp', serverTask(outDir, false));
42
58
task ( ':serve:e2eapp:stop' , gulpConnect . serverClose ) ;
43
59
44
60
/** Builds and serves the e2e app. */
45
- task ( 'serve:e2eapp' , sequenceTask ( 'build:e2eapp ' , ':serve:e2eapp' ) ) ;
61
+ task ( 'serve:e2eapp' , sequenceTask ( 'e2e-app:build ' , ':serve:e2eapp' ) ) ;
46
62
47
63
/**
48
64
* [Watch task] Builds and serves e2e app, rebuilding whenever the sources change.
49
65
* This should only be used when running e2e tests locally.
50
66
*/
51
67
task ( 'serve:e2eapp:watch' , [ 'serve:e2eapp' , 'material:watch' , ':watch:e2eapp' ] ) ;
52
68
53
- /**
54
- * Builds and serves the e2e-app and runs protractor once the e2e-app is ready.
55
- */
56
- task ( 'e2e' , sequenceTask (
57
- [ ':test:protractor:setup' , 'serve:e2eapp' ] ,
58
- ':test:protractor' ,
59
- ':serve:e2eapp:stop' ,
60
- 'screenshots' ,
61
- ) ) ;
69
+ // As a workaround for https://github.com/angular/angular/issues/12249, we need to
70
+ // copy the Material and CDK ESM output inside of the demo-app output.
71
+ task ( 'e2e-app:copy-release' , ( ) => {
72
+ copySync ( join ( DIST_RELEASES , 'material' ) , join ( outDir , 'material' ) ) ;
73
+ copySync ( join ( DIST_RELEASES , 'cdk' ) , join ( outDir , 'cdk' ) ) ;
74
+ } ) ;
62
75
0 commit comments