⚠️ This lesson is retired and might contain outdated information.

Using a Gatsby Plugin

Khaled Garbaya
InstructorKhaled Garbaya
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 2 years ago

A Gatsby plugin is a Node package that uses the Gatsby APIs under the hood.

You can use a plugin to source data into your site, transform content or enhance the output of your site like adding google analytics etc...

Gatsby plugins can be categorized into 3 types:

  • A Gatsby Source plugin (e.g: gatsby-source-contentful pulls data from Contentful)
  • A Gatsby Transformer Plugin (e.g: gatsby-transformer-remark convert markdown text to html)
  • A Gatsby Plugin (e.g: gatsby-plugin-google-analytics adds Google analytics in your site)

How to install and configure a plugin

  1. Install a plugin you can run the command npm install plugin-name e.g npm install gatsby-plugin-postcss.

  2. Add the plugin to your gatsby-config.js file

In this lesson, you learn how to use gatsby-plugin-postcss to add tailwindcss support to your project

Instructor: [0:00] First, let's install tailwindcss as a dev dependency. After that, we need to install the gatsby-plugin-postcss. Let's go to our project and create a gatsby-config.js. In there, let's add our new plugin. Next, let's create a postcss.config.js file and add tailwind as a plugin.

[0:40] Finally, inside of src, let's create a CSS folder. Inside of that, let's create an index.css file. Let's add the tailwind base. Let's go to our components inside the flyout. Since this is used in every page, we can import our CSS in here.

[0:58] Here we will simply import the index.css file. Let's hit Save and run our server. You can see here, the CSS has changed and this is using tailwind.

egghead
egghead
~ 36 seconds ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today