@@ -4,27 +4,10 @@ import React, { PropTypes as PT, PureComponent } from 'react'
4
4
import fs from 'fs'
5
5
import { publicDir } from '../../../config/paths'
6
6
import { renderToStaticMarkup } from 'react-dom/server'
7
- import { version } from '../../../package.json'
8
7
9
- const encoding = { encoding : 'utf8' }
8
+ import './html.css' // eslint-disable-line sort-imports
10
9
11
- import './html.css'
12
-
13
- export default class Html extends Component {
14
-
15
- static propTypes = {
16
- app : PT . string . isRequired ,
17
- content : PT . string . isRequired ,
18
- initalState : PT . object . isRequired ,
19
- inline : DEBUG ? PT . bool . isRequired : PT . string . isRequired ,
20
- vendor : PT . string . isRequired
21
- }
22
-
23
- static defaultProps = {
24
- app : Html . getScript ( appName ) ,
25
- vendor : Html . getScript ( vendorName ) ,
26
- inline : Html . getWebpackJsonpInlineScript ( )
27
- }
10
+ class Html extends PureComponent {
28
11
29
12
static getDoctype ( ) {
30
13
return '<!doctype html>'
@@ -33,23 +16,25 @@ export default class Html extends Component {
33
16
static getScript ( name ) {
34
17
if ( DEBUG ) return `/${ name } .js`
35
18
36
- const file = fs . readFileSync ( `${ publicDir } /${ statsName } .json` , encoding )
19
+ const file = fs . readFileSync ( `${ publicDir } /${ statsName } .json` )
37
20
const stats = JSON . parse ( file )
38
21
39
- return `/${ stats . assetsByChunkName [ name ] } `
22
+ return name === 'app' && ! DEBUG
23
+ ? `/${ stats . assetsByChunkName [ name ] [ 0 ] } `
24
+ : `/${ stats . assetsByChunkName [ name ] } `
40
25
}
41
26
42
27
static getWebpackJsonpInlineScript ( ) {
43
28
if ( DEBUG ) return false
44
- return fs . readFileSync ( `${ publicDir } /${ inlineName } .js` , encoding )
29
+ return fs . readFileSync ( `${ publicDir } /${ inlineName } .js` )
45
30
}
46
31
47
32
static renderToStaticMarkup ( props ) {
48
33
return Html . getDoctype ( ) + renderToStaticMarkup ( < Html { ...props } /> )
49
34
}
50
35
51
36
render ( ) {
52
- const { app, content, inline , vendor , initalState } = this . props
37
+ const { app, content, initalState , inline , vendor } = this . props
53
38
54
39
return (
55
40
< html
@@ -82,20 +67,53 @@ export default class Html extends Component {
82
67
< meta content = 'true' name = 'HandheldFriendly' />
83
68
< meta content = '320' name = 'MobileOptimized' />
84
69
85
- < link href = '/style.css' rel = 'stylesheet' />
70
+ < link href = '/apple-icon-57x57.png' rel = 'apple-touch-icon' sizes = '57x57' />
71
+ < link href = '/apple-icon-60x60.png' rel = 'apple-touch-icon' sizes = '60x60' />
72
+ < link href = '/apple-icon-72x72.png' rel = 'apple-touch-icon' sizes = '72x72' />
73
+ < link href = '/apple-icon-76x76.png' rel = 'apple-touch-icon' sizes = '76x76' />
74
+ < link href = '/apple-icon-114x114.png' rel = 'apple-touch-icon' sizes = '114x114' />
75
+ < link href = '/apple-icon-120x120.png' rel = 'apple-touch-icon' sizes = '120x120' />
76
+ < link href = '/apple-icon-144x144.png' rel = 'apple-touch-icon' sizes = '144x144' />
77
+ < link href = '/apple-icon-152x152.png' rel = 'apple-touch-icon' sizes = '152x152' />
78
+ < link href = '/apple-icon-180x180.png' rel = 'apple-touch-icon' sizes = '180x180' />
79
+ < link href = '/android-icon-192x192.png' rel = 'icon' sizes = '192x192' type = 'image/png' />
80
+ < link href = '/favicon-32x32.png' rel = 'icon' sizes = '32x32' type = 'image/png' />
81
+ < link href = '/favicon-96x96.png' rel = 'icon' sizes = '96x96' type = 'image/png' />
82
+ < link href = '/favicon-16x16.png' rel = 'icon' sizes = '16x16' type = 'image/png' />
83
+
84
+ < meta content = '#ffffff' name = 'msapplication-TileColor' />
85
+ < meta content = '/ms-icon-144x144.png' name = 'msapplication-TileImage' />
86
+ < meta content = '#ffffff' name = 'theme-color' />
86
87
88
+ < link href = '/style.css' rel = 'stylesheet' />
87
89
</ head >
88
90
< body >
89
91
< div id = 'app' >
90
92
< div dangerouslySetInnerHTML = { { __html : content } } />
91
93
</ div >
92
94
95
+ < script dangerouslySetInnerHTML = { { __html : `window.__INITAL_STATE__ = ${ JSON . stringify ( initalState ) } ` } } />
93
96
{ inline && < script dangerouslySetInnerHTML = { { __html : inline } } /> }
94
- < script dangerouslySetInnerHTML = { { __html : `window.__INITIAL_STATE__=${ JSON . stringify ( initalState ) } ` } } />
95
97
< script src = { vendor } />
96
98
< script src = { app } />
97
99
</ body >
98
100
</ html >
99
101
)
100
102
}
101
103
}
104
+
105
+ Html . propTypes = {
106
+ app : PT . string . isRequired ,
107
+ content : PT . string . isRequired ,
108
+ initalState : PT . object . isRequired ,
109
+ vendor : PT . string . isRequired ,
110
+ inline : DEBUG ? PT . bool : PT . string ,
111
+ }
112
+
113
+ Html . defaultProps = {
114
+ app : Html . getScript ( appName ) ,
115
+ vendor : Html . getScript ( vendorName ) ,
116
+ inline : Html . getWebpackJsonpInlineScript ( ) ,
117
+ }
118
+
119
+ export default Html
0 commit comments