Emily Xiong efd706ff5f
feat(gatsby): add style-jsx support for gatsby (#5300)
add style-jsx option for gatsby
add plugin to add _JSXStyle to global
2021-05-03 13:19:32 -04:00

19 lines
431 B
TypeScript

/*
* This plugin is a workaround to a known styled-jsx issue.
*
* See: https://github.com/vercel/styled-jsx/issues/695
*
* If the issue is fixed in the future, we should be able to remove this patch.
*/
function onPreRenderHTML(_, pluginOptions: any) {
try {
const _JSXStyle = require('styled-jsx/style').default;
Object.assign(global, { _JSXStyle });
} catch {
// nothing
}
}
export { onPreRenderHTML };