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 favicons from './favicons';
|
||||||
import meta from './meta';
|
import meta from './meta';
|
||||||
import styleSheets from './styleSheets';
|
|
||||||
import mathjax from './mathjax';
|
import mathjax from './mathjax';
|
||||||
import sassjs from './sassjs';
|
import sassjs from './sassjs';
|
||||||
|
|
||||||
const metaAndStyleSheets = meta
|
const metaAndStyleSheets = meta
|
||||||
.concat(favicons, styleSheets, mathjax, sassjs)
|
.concat(favicons, mathjax, sassjs)
|
||||||
.map((element, i) => ({ ...element, key: `meta-stylesheet-${i}` }));
|
.map((element, i) => ({ ...element, key: `meta-stylesheet-${i}` }));
|
||||||
|
|
||||||
export default metaAndStyleSheets;
|
export default metaAndStyleSheets;
|
||||||
|
@ -2,12 +2,15 @@ import React from 'react';
|
|||||||
import styleSheets from './styleSheets';
|
import styleSheets from './styleSheets';
|
||||||
|
|
||||||
const preloads = styleSheets.map((styleSheet, i) => (
|
const preloads = styleSheets.map((styleSheet, i) => (
|
||||||
|
<React.Fragment>
|
||||||
<link
|
<link
|
||||||
as='style'
|
as='style'
|
||||||
href={styleSheet.props.href}
|
href={styleSheet.props.href}
|
||||||
key={`preload-${i}`}
|
key={`preload-${i}`}
|
||||||
rel='preload'
|
rel='preload'
|
||||||
/>
|
/>
|
||||||
|
{styleSheet}
|
||||||
|
</React.Fragment>
|
||||||
));
|
));
|
||||||
|
|
||||||
export default preloads;
|
export default preloads;
|
||||||
|
@ -3,15 +3,6 @@ import PropTypes from 'prop-types';
|
|||||||
|
|
||||||
import preloads from './head/preloads';
|
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
|
// These props are coming from Gatsby, we shouldn't have to worry about them
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
body: PropTypes.any,
|
body: PropTypes.any,
|
||||||
@ -31,21 +22,11 @@ function HTML(props) {
|
|||||||
preBodyComponents,
|
preBodyComponents,
|
||||||
postBodyComponents
|
postBodyComponents
|
||||||
} = props;
|
} = props;
|
||||||
let css;
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
css = (
|
|
||||||
<style
|
|
||||||
dangerouslySetInnerHTML={{ __html: stylesStr }}
|
|
||||||
id='gatsby-inlined-css'
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<html {...htmlAttributes}>
|
<html {...htmlAttributes}>
|
||||||
<head>
|
<head>
|
||||||
{preloads}
|
{preloads}
|
||||||
{headComponents}
|
{headComponents}
|
||||||
{css}
|
|
||||||
</head>
|
</head>
|
||||||
<body {...bodyAttributes}>
|
<body {...bodyAttributes}>
|
||||||
{preBodyComponents}
|
{preBodyComponents}
|
||||||
|
Reference in New Issue
Block a user