This repository was archived by the owner on Sep 10, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " app-shell" ,
3
- "version" : " 0.1.120 " ,
3
+ "version" : " 0.1.141 " ,
4
4
"private" : true ,
5
5
"license" : " Apache" ,
6
6
"engines" : {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ var fs = require ( 'fs' ) ;
4
+ var path = require ( 'path' ) ;
5
+
3
6
function StaticPageController ( ) {
4
7
5
8
}
6
9
10
+ function prepareData ( config ) {
11
+ // Concat inline styles for document <head>
12
+ var flattenedStyles = '' ;
13
+ var pathPrefix = '/../../dist/' ;
14
+ config . inlineStyles . forEach ( function ( file ) {
15
+ flattenedStyles += fs . readFileSync ( path . resolve ( __dirname ) + pathPrefix + file ) ;
16
+ } ) ;
17
+ // Replace array with flattened string of content
18
+ config . inlineStyles = flattenedStyles ;
19
+ return config ;
20
+ } ;
21
+
7
22
StaticPageController . prototype . onRequest = function ( req , res ) {
8
23
switch ( req . path ) {
9
24
case '/' :
10
- res . render ( 'index' , {
25
+ res . render ( 'index' , prepareData ( {
11
26
inlineStyles : [ '/styles/core.css' ] ,
12
27
remoteStyles : [ ] ,
13
28
inlineScripts : [ ] ,
14
29
remoteScripts : [ '/scripts/static-page.js' ]
15
- } ) ;
30
+ } ) ) ;
16
31
break ;
17
32
case '/url-1' :
18
- res . render ( 'url-1' , {
33
+ res . render ( 'url-1' , prepareData ( {
19
34
inlineStyles : [ '/styles/core.css' ] ,
20
35
remoteStyles : [ ] ,
21
36
inlineScripts : [ ] ,
22
37
remoteScripts : [ '/scripts/static-page.js' ]
23
- } ) ;
38
+ } ) ) ;
24
39
break ;
25
40
case '/url-2' :
26
- res . render ( 'url-2' , {
41
+ res . render ( 'url-2' , prepareData ( {
27
42
inlineStyles : [ '/styles/core.css' ] ,
28
43
remoteStyles : [ ] ,
29
44
inlineScripts : [ ] ,
30
45
remoteScripts : [ '/scripts/static-page.js' ]
31
- } ) ;
46
+ } ) ) ;
32
47
break ;
33
48
default :
34
49
res . status ( 404 ) . send ( ) ;
Original file line number Diff line number Diff line change 11
11
<link rel =" manifest" href =" /manifest.json" >
12
12
<link rel =" icon" href =" /images/chrome-touch-icon-192x192.png" sizes =" 192x192" type =" image/png" >
13
13
14
- {{ #each inlineStyles }}
15
- <!-- TODO: Inline these styles -->
16
- <link rel =" stylesheet" type =" text/css" href =" {{ this }} " >
17
- {{ ~/each }}
14
+ <style >{{{inlineStyles }}}</style >
18
15
</head >
19
16
<body >
20
17
You can’t perform that action at this time.
0 commit comments