Your Teacher
Chris Oliver
Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.
About This Episode
CSS frameworks like Tailwind, Bootstrap, Foundation, etc all come with many CSS classes you probably aren't using. This creates huge CSS files unless we use a tool like PurgeCSS to look through our code and remove the unused classes.
Notes
Resources
Code
yarn add @fullhuman/postcss-purgecss
// postcss.config.js
let environment = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
require('postcss-import'),
require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009'
},
stage: 3
}),
]
}
// Only run PurgeCSS in production (you can also add staging here)
if (process.env.RAILS_ENV === "production") {
environment.plugins.push(
require('@fullhuman/postcss-purgecss')({
content: [
'./app/**/*.html.erb',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/javascript/**/*.vue',
'./app/javascript/**/*.jsx',
],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
})
)
}
module.exports = environment
Deploying Rails To Production
0% Complete
1
Deploying To Production on Heroku with Puma
24m
2
How to Deploy ActionCable and Rails 5 To Production
18m
3
Deploying Sidekiq To Heroku
17m
4
Feature Flags with Rollout
17m
5
Security Hardening Servers with Fail2Ban
11m
6
Server Administration with Cockpit
8m
7
How to Deploy Rails to Production on Ubuntu 18.04 Bionic Beaver
32m
How to Remove Unused CSS Classes from Tailwind CSS, Boostrap, and more with PurgeCSS
11m
9
Continuous Deployment with Rails & GitHub Actions
10m
10
How to deploy Rails to a Staging Environment
16m
11
How to manage and run Maintenance Tasks for Rails in Production
9m
12
How to Deploy Rails to Fly.io
10m
13
How to Deploy Rails to Render
25m