-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstylesheet.js
28 lines (22 loc) · 1.04 KB
/
stylesheet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* global __webpack_css_chunk_hashes__, __webpack_public_path__, __webpack_websocket_port__, __webpack_chunkname__ */
/*
Links to the stylesheet and adds hot reloading for stylesheets
*/
import hotCssReplacementClient from './hot-css-replacement-client?transpiled-javascript-string'
const isWatch = process.env.WATCH
export const hotReloadClient = isWatch ? createHotReloadClient() : null
export default __webpack_css_chunk_hashes__
.map(cssHash => <link href={`${__webpack_public_path__ + cssHash}.css`} rel='stylesheet' type='text/css' key={`stylesheet_${cssHash}`} />)
.concat(hotReloadClient)
.filter(Boolean)
function createHotReloadClient() {
const [ port, cssHashes, chunkName, publicPath ] = [ __webpack_websocket_port__, __webpack_css_chunk_hashes__, __webpack_chunkname__, __webpack_public_path__ ]
return (
<script
key='stylesheet_hotCssReplacementClient'
dangerouslySetInnerHTML={{
__html: `(${hotCssReplacementClient})(${port}, ${JSON.stringify(cssHashes)}, '${chunkName}', '${publicPath}')`
}}
/>
)
}