Skip to content

Commit a28f9b5

Browse files
committed
fix: purge css
1 parent a2c16f3 commit a28f9b5

4 files changed

Lines changed: 32 additions & 6 deletions

File tree

.github/workflows/jekyll.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ jobs:
4747
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
4848
env:
4949
JEKYLL_ENV: production
50+
- name: Setup Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: '20'
54+
- name: Purge unused CSS
55+
run: |
56+
npx --yes purgecss \
57+
--css _site/assets/plugins/bootstrap/css/bootstrap.min.css \
58+
--content '_site/**/*.html' \
59+
--output _site/assets/plugins/bootstrap/css/
60+
npx purgecss \
61+
--css _site/assets/fontawesome/css/all.min.css \
62+
--content '_site/**/*.html' \
63+
--safelist pattern:/^fa/ \
64+
--output _site/assets/fontawesome/css/
5065
- name: Upload artifact
5166
# Automatically uploads an artifact from the './_site' directory by default
5267
uses: actions/upload-pages-artifact@v3

assets/fontawesome/css/all.min.css

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/plugins/bootstrap/css/bootstrap.min.css

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

purgecss.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Run after `bundle exec jekyll build` to strip unused CSS.
2+
// Usage: npx purgecss --config purgecss.config.js
3+
module.exports = {
4+
content: ['_site/**/*.html'],
5+
css: [
6+
'assets/plugins/bootstrap/css/bootstrap.min.css',
7+
'assets/fontawesome/css/all.min.css',
8+
],
9+
output: undefined, // overwrite in-place
10+
safelist: {
11+
// Keep all FontAwesome utility classes (fa, fab, fas, far, fa-*)
12+
pattern: /^fa/,
13+
},
14+
};

0 commit comments

Comments
 (0)