@@ -9,12 +9,12 @@ const files = fs.readdirSync(`${process.cwd()}/dist-server`);
99
1010global [ 'window' ] = win ;
1111Object . defineProperty ( win . document . body . style , 'transform' , {
12- value : ( ) => {
13- return {
14- enumerable : true ,
15- configurable : true
16- } ;
17- } ,
12+ value : ( ) => {
13+ return {
14+ enumerable : true ,
15+ configurable : true ,
16+ } ;
17+ } ,
1818} ) ;
1919global [ 'document' ] = win . document ;
2020global [ 'CSS' ] = null ;
@@ -39,7 +39,7 @@ import { renderModuleFactory } from '@angular/platform-server';
3939import { ROUTES } from './static.paths' ;
4040
4141// * NOTE :: leave this as require() since this file is built Dynamically from webpack
42- const mainFiles = files . filter ( file => file . startsWith ( 'main' ) ) ;
42+ const mainFiles = files . filter ( ( file ) => file . startsWith ( 'main' ) ) ;
4343const hash = mainFiles [ 0 ] . split ( '.' ) [ 1 ] ;
4444const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require ( `./dist-server/main.${ hash } ` ) ;
4545import { REQUEST , RESPONSE } from '@nguniversal/express-engine/tokens' ;
@@ -52,34 +52,40 @@ const index = readFileSync(join('dist', 'index.html'), 'utf8');
5252let previousRender = Promise . resolve ( ) ;
5353
5454// Iterate each route path
55- ROUTES . forEach ( route => {
56- const fullPath = join ( BROWSER_FOLDER , route ) ;
55+ ROUTES . forEach ( ( route ) => {
56+ const fullPath = join ( BROWSER_FOLDER , route ) ;
5757
58- // Make sure the directory structure is there
59- if ( ! existsSync ( fullPath ) ) {
60- let syncpath = BROWSER_FOLDER ;
61- route . split ( '/' ) . forEach ( element => {
62- syncpath = syncpath + '/' + element ;
63- mkdirSync ( syncpath ) ;
64- } ) ;
65- }
58+ // Make sure the directory structure is there
59+ if ( ! existsSync ( fullPath ) ) {
60+ let syncpath = BROWSER_FOLDER ;
61+ route . split ( '/' ) . forEach ( ( element ) => {
62+ syncpath = syncpath + '/' + element ;
63+ mkdirSync ( syncpath ) ;
64+ } ) ;
65+ }
6666
67- // Writes rendered HTML to index.html, replacing the file if it already exists.
68- previousRender = previousRender . then ( _ => renderModuleFactory ( AppServerModuleNgFactory , {
67+ // Writes rendered HTML to index.html, replacing the file if it already exists.
68+ previousRender = previousRender
69+ . then ( ( _ ) =>
70+ renderModuleFactory ( AppServerModuleNgFactory , {
6971 document : index ,
7072 url : route ,
7173 extraProviders : [
72- provideModuleMap ( LAZY_MODULE_MAP ) ,
73- {
74- provide : REQUEST , useValue : null
75- } ,
76- {
77- provide : RESPONSE , useValue : null
78- } ,
79- {
80- provide : 'ORIGIN_URL' ,
81- useValue : environment . host
82- }
83- ]
84- } ) ) . then ( html => writeFileSync ( join ( fullPath , 'index.html' ) , html ) ) ;
74+ provideModuleMap ( LAZY_MODULE_MAP ) ,
75+ {
76+ provide : REQUEST ,
77+ useValue : null ,
78+ } ,
79+ {
80+ provide : RESPONSE ,
81+ useValue : null ,
82+ } ,
83+ {
84+ provide : 'ORIGIN_URL' ,
85+ useValue : environment . host ,
86+ } ,
87+ ] ,
88+ } ) ,
89+ )
90+ . then ( ( html ) => writeFileSync ( join ( fullPath , 'index.html' ) , html ) ) ;
8591} ) ;
0 commit comments