@@ -7,34 +7,39 @@ import {copySync} from 'fs-extra';
7
7
const appDir = join ( SOURCE_ROOT , 'universal-app' ) ;
8
8
const outDir = join ( DIST_ROOT , 'packages' , 'universal-app' ) ;
9
9
10
- /** Path to the universal-app tsconfig files. */
11
- const tsconfigAppPath = join ( appDir , 'tsconfig-build.json' ) ;
10
+ // Paths to the different tsconfig files of the Universal app.
11
+ // Building the sources in the output directory is part of the workaround for
12
+ // https://github.com/angular/angular/issues/12249
13
+ const tsconfigAppPath = join ( outDir , 'tsconfig-build.json' ) ;
12
14
const tsconfigPrerenderPath = join ( outDir , 'tsconfig-prerender.json' ) ;
13
15
14
- /** Glob that matches all assets that need to copied to the dist. */
15
- const assetsGlob = join ( appDir , '**/*.+(html|css|json)' ) ;
16
-
17
- /** Path to the file that prerenders the universal app using platform-server. */
18
- const prerenderFile = join ( appDir , 'prerender.ts' ) ;
19
-
20
16
/** Path to the compiled prerender file. Running this file just dumps the HTML output for now. */
21
17
const prerenderOutFile = join ( outDir , 'prerender.js' ) ;
22
18
23
- task ( 'universal:test-prerender' , [ 'universal:build' ] , execTask ( 'node' , [ prerenderOutFile ] ) ) ;
19
+ /** Task that builds the universal-app and runs the prerender script. */
20
+ task ( 'universal:test-prerender' , [ 'universal:build' ] , execTask (
21
+ // Runs node with the tsconfig-paths module to alias the @angular/material dependency.
22
+ 'node' , [ '-r' , 'tsconfig-paths/register' , prerenderOutFile ] , {
23
+ env : { TS_NODE_PROJECT : tsconfigPrerenderPath }
24
+ }
25
+ ) ) ;
24
26
25
27
task ( 'universal:build' , sequenceTask (
26
28
'clean' ,
27
29
[ 'material:build-release' , 'cdk:build-release' ] ,
28
- 'universal:copy-release' ,
29
- [ 'universal:build-app-ts' , 'universal:copy-app-assets' , 'universal:copy-prerender-source' ] ,
30
+ [ 'universal:copy-release' , 'universal:copy-files' ] ,
31
+ 'universal:build-app-ts' ,
30
32
'universal:build-prerender-ts'
31
33
) ) ;
32
34
35
+ /** Task that builds the universal app in the output directory. */
33
36
task ( 'universal:build-app-ts' , ngcBuildTask ( tsconfigAppPath ) ) ;
34
- task ( 'universal:copy-app-assets' , copyTask ( assetsGlob , outDir ) ) ;
35
37
38
+ /** Task that copies all files to the output directory. */
39
+ task ( 'universal:copy-files' , copyTask ( appDir , outDir ) ) ;
40
+
41
+ /** Task that builds the prerender script in the output directory. */
36
42
task ( 'universal:build-prerender-ts' , tsBuildTask ( tsconfigPrerenderPath ) ) ;
37
- task ( 'universal:copy-prerender-source' , copyTask ( prerenderFile , outDir ) ) ;
38
43
39
44
// As a workaround for https://github.com/angular/angular/issues/12249, we need to
40
45
// copy the Material and CDK ESM output inside of the universal-app output.
0 commit comments