Skip to content

Instantly share code, notes, and snippets.

@laurendorman
Created March 18, 2020 16:42
Show Gist options
  • Save laurendorman/d6fbebbd794cbf12ffedccb490bf3e2b to your computer and use it in GitHub Desktop.
Save laurendorman/d6fbebbd794cbf12ffedccb490bf3e2b to your computer and use it in GitHub Desktop.
Gatsby + TailwindCSS + PostCSS + PurgeCSS
{
"name": "example",
"private": true,
"description": "A simple starter to get up running with Gatsby + TailwindCSS + PostCSS + PurgeCSS",
"version": "0.1.0",
"author": "Lauren Dorman <lauren@yams.studio>",
"dependencies": {
"gatsby": "^2.19.6",
"gatsby-image": "^2.2.39",
"gatsby-plugin-manifest": "^2.2.38",
"gatsby-plugin-offline": "^2.2.10",
"gatsby-plugin-postcss": "^2.1.19",
"gatsby-plugin-react-helmet": "^3.1.21",
"gatsby-plugin-sharp": "^2.4.2",
"gatsby-source-filesystem": "^2.1.46",
"gatsby-transformer-sharp": "^2.3.13",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "^5.2.1"
},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^1.3.0",
"postcss-cli": "^6.1.3",
"postcss-import": "^12.0.1",
"postcss-preset-env": "^6.7.0",
"prettier": "^1.19.1",
"tailwindcss": "^1.1.4"
},
"keywords": [
"gatsby",
"tailwindcss",
"postcss",
"purgecss"
],
"license": "MIT",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"css": "postcss src/styles/index.css -o public/static/css/styles.css",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing \""
}
}
module.exports = () => ({
plugins: [
require("postcss-preset-env")({
stage: 0,
}),
require("postcss-import"),
// See: https://www.gatsbyjs.org/docs/tailwind-css/#option-1-postcss
require("tailwindcss")("./tailwind.config.js"),
require("autoprefixer"),
// See: https://purgecss.com/plugins/postcss.html#usage
require("@fullhuman/postcss-purgecss")({
content: ["./src/**/*.js"],
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
whitelist: ['html', 'body', 'gatsby-focus-wrapper']
}),
require("cssnano")({
preset: "default",
}),
],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment