remove inlined css in htmljs

This commit is contained in:
ValeraS
2018-09-13 12:43:29 +03:00
committed by Mrugesh Mohapatra
parent d85ee836d3
commit 5869ea4b33
3 changed files with 10 additions and 27 deletions

View File

@ -1,11 +1,10 @@
import favicons from './favicons';
import meta from './meta';
import styleSheets from './styleSheets';
import mathjax from './mathjax';
import sassjs from './sassjs';
const metaAndStyleSheets = meta
.concat(favicons, styleSheets, mathjax, sassjs)
.concat(favicons, mathjax, sassjs)
.map((element, i) => ({ ...element, key: `meta-stylesheet-${i}` }));
export default metaAndStyleSheets;

View File

@ -2,12 +2,15 @@ import React from 'react';
import styleSheets from './styleSheets';
const preloads = styleSheets.map((styleSheet, i) => (
<link
as='style'
href={styleSheet.props.href}
key={`preload-${i}`}
rel='preload'
/>
<React.Fragment>
<link
as='style'
href={styleSheet.props.href}
key={`preload-${i}`}
rel='preload'
/>
{styleSheet}
</React.Fragment>
));
export default preloads;

View File

@ -3,15 +3,6 @@ import PropTypes from 'prop-types';
import preloads from './head/preloads';
let stylesStr;
if (process.env.NODE_ENV === 'production') {
try {
stylesStr = require('!raw-loader!../public/styles.css');
} catch (e) {
console.log(e);
}
}
// These props are coming from Gatsby, we shouldn't have to worry about them
const propTypes = {
body: PropTypes.any,
@ -31,21 +22,11 @@ function HTML(props) {
preBodyComponents,
postBodyComponents
} = props;
let css;
if (process.env.NODE_ENV === 'production') {
css = (
<style
dangerouslySetInnerHTML={{ __html: stylesStr }}
id='gatsby-inlined-css'
/>
);
}
return (
<html {...htmlAttributes}>
<head>
{preloads}
{headComponents}
{css}
</head>
<body {...bodyAttributes}>
{preBodyComponents}