greglobinski / gatsby-starter-hero-blog

A ready to use, easy to customize, fully equipped GatsbyJS starter with a 'Hero' section on the home page.
https://gatsby-starter-hero-blog.greglobinski.com/
MIT License
514 stars 209 forks source link

Use of buggy plugin gatsby-plugin-styled-jsx-postcss #110

Open edmcman opened 4 years ago

edmcman commented 4 years ago

This project is using gatsby-plugin-styled-jsx-postcss which is known to cause lockups in some versions of nodejs and gatsbyjs. For more information please see this issue: https://github.com/gatsbyjs/gatsby/issues/21885

My website is based on this starter (thanks! it's great) and I have experienced this first-hand when upgrading package versions. I personally switched to sass.

lucaskjaero commented 2 years ago

Hi @edmcman, I'm in a similar situation. Do you have some pointers on how to switch to sass? I've gotten rid of most of the postcss plugins, but am stuck on media queries and nesting.

edmcman commented 2 years ago

@lucaskjaero Sass supports nesting out of the box. I don't remember any issues with media queries.

diff --git a/gatsby-config.js b/gatsby-config.js
index a30d21e..cfb5c1a 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -59,9 +59,14 @@ module.exports = {
     // Add typescript stack into webpack
     `gatsby-plugin-typescript`,

-    // Use styled jsx and PostCSS
+    // Use styled jsx and sass
+    {
+      resolve: `gatsby-plugin-styled-jsx`,
+      options: {
+        jsxPlugins: ['styled-jsx-plugin-sass']
+      }
+    },
     `gatsby-plugin-styled-jsx`, // The plugin's code is inserted directly to gatsby-node.js and gatsby-ssr.js files
-    `gatsby-plugin-styled-jsx-postcss`, // As above