remove inlined css in htmljs
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
d85ee836d3
commit
5869ea4b33
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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}
|
||||
|
Reference in New Issue
Block a user