1
1
import { task , watch } from 'gulp' ;
2
2
import * as path from 'path' ;
3
3
4
- import { SOURCE_ROOT , DIST_COMPONENTS_ROOT , PROJECT_ROOT } from '../constants' ;
4
+ import { DIST_COMPONENTS_ROOT , PROJECT_ROOT , COMPONENTS_DIR } from '../constants' ;
5
5
import { sassBuildTask , tsBuildTask , execNodeTask , copyTask , sequenceTask } from '../task_helpers' ;
6
6
import { writeFileSync } from 'fs' ;
7
7
@@ -17,42 +17,32 @@ const rollup = require('rollup').rollup;
17
17
// When `tsconfig-spec.json` is used, we are outputting CommonJS modules. This is used
18
18
// for unit tests (karma).
19
19
20
- /** Path to the root of the Angular Material component library. */
21
- const componentsDir = path . join ( SOURCE_ROOT , 'lib' ) ;
22
-
23
20
/** Path to the tsconfig used for ESM output. */
24
- const tsconfigPath = path . relative ( PROJECT_ROOT , path . join ( componentsDir , 'tsconfig.json' ) ) ;
21
+ const tsconfigPath = path . relative ( PROJECT_ROOT , path . join ( COMPONENTS_DIR , 'tsconfig.json' ) ) ;
25
22
26
23
27
24
/** [Watch task] Rebuilds (ESM output) whenever ts, scss, or html sources change. */
28
25
task ( ':watch:components' , ( ) => {
29
- watch ( path . join ( componentsDir , '**/*.ts' ) , [ ':build:components:rollup' ] ) ;
30
- watch ( path . join ( componentsDir , '**/*.scss' ) , [ ':build:components:rollup' ] ) ;
31
- watch ( path . join ( componentsDir , '**/*.html' ) , [ ':build:components:rollup' ] ) ;
32
- } ) ;
33
-
34
- /** [Watch task] Rebuilds for tests (CJS output) whenever ts, scss, or html sources change. */
35
- task ( ':watch:components:spec' , ( ) => {
36
- watch ( path . join ( componentsDir , '**/*.ts' ) , [ ':build:components:spec' ] ) ;
37
- watch ( path . join ( componentsDir , '**/*.scss' ) , [ ':build:components:scss' ] ) ;
38
- watch ( path . join ( componentsDir , '**/*.html' ) , [ ':build:components:assets' ] ) ;
26
+ watch ( path . join ( COMPONENTS_DIR , '**/*.ts' ) , [ ':build:components:rollup' ] ) ;
27
+ watch ( path . join ( COMPONENTS_DIR , '**/*.scss' ) , [ ':build:components:rollup' ] ) ;
28
+ watch ( path . join ( COMPONENTS_DIR , '**/*.html' ) , [ ':build:components:rollup' ] ) ;
39
29
} ) ;
40
30
41
31
42
32
/** Builds component typescript only (ESM output). */
43
- task ( ':build:components:ts' , tsBuildTask ( componentsDir , 'tsconfig-srcs.json' ) ) ;
33
+ task ( ':build:components:ts' , tsBuildTask ( COMPONENTS_DIR , 'tsconfig-srcs.json' ) ) ;
44
34
45
35
/** Builds components typescript for tests (CJS output). */
46
- task ( ':build:components:spec' , tsBuildTask ( componentsDir ) ) ;
36
+ task ( ':build:components:spec' , tsBuildTask ( COMPONENTS_DIR ) ) ;
47
37
48
38
/** Copies assets (html, markdown) to build output. */
49
39
task ( ':build:components:assets' , copyTask ( [
50
- path . join ( componentsDir , '**/*.!(ts|spec.ts)' ) ,
40
+ path . join ( COMPONENTS_DIR , '**/*.!(ts|spec.ts)' ) ,
51
41
path . join ( PROJECT_ROOT , 'README.md' ) ,
52
42
] , DIST_COMPONENTS_ROOT ) ) ;
53
43
54
44
/** Builds scss into css. */
55
- task ( ':build:components:scss' , sassBuildTask ( DIST_COMPONENTS_ROOT , componentsDir ) ) ;
45
+ task ( ':build:components:scss' , sassBuildTask ( DIST_COMPONENTS_ROOT , COMPONENTS_DIR ) ) ;
56
46
57
47
/** Builds the UMD bundle for all of Angular Material. */
58
48
task ( ':build:components:rollup' , [ ':build:components:inline' ] , ( ) => {
0 commit comments