UNPKG

reacthtmlpack

Version:

Using HTML templates as entry points for webpack

45 lines (40 loc) 1.01 kB
import { default as React, Component, PropTypes, } from "react"; export default class WebpackStyleEntry extends Component { static propTypes = { chunkName: PropTypes.string.isRequired, chunkFilepath: PropTypes.oneOfType([ PropTypes.string, PropTypes.arrayOf(PropTypes.string), ]).isRequired, configFilepath: PropTypes.string.isRequired, // Generated later. outputAssetList: PropTypes.arrayOf(PropTypes.shape({ publicFilepath: PropTypes.string.isRequired, })), } render () { const { chunkName, chunkFilepath, configFilepath, outputAssetList, ...restProps, } = this.props; if (outputAssetList) { const [outputPublicFilepath] = outputAssetList .map(({publicFilepath}) => publicFilepath) .filter(::/\.css$/.test); return ( <link {...restProps} rel="stylesheet" href={outputPublicFilepath} /> ); } else { return ( <noscript /> ); } } }