These steps show how to install Tailwind CSS in a Pelican project, purge and minify it so you don't have to reference a 3+ MB CSS file but only several kB.
-
virtualenv venv
-
. venv/bin/activate
-
pip install nodeenv
-
nodeenv env
-
. env/bin/activate
-
npm install postcss postcss-cli autoprefixer tailwindcss purgecss cssnano
-
npm init -y
-
npx tailwindcss-cli@latest build -o css/tailwind.css
-
Create
postcss.config.js
:module.exports = { plugins: [ require("tailwindcss"), require("autoprefixer"), require("cssnano") ], };
-
Create
tailwind.config.js
referencing your theme's HTML files:module.exports = { purge: [ './themes/mynewtheme/templates/*.html', ], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: { extend: {}, }, plugins: [], }
-
Update
package.json
and replace"main"
and"scripts"
with:"main": "postcss.config.js", "scripts": { "build": "postcss css/tailwind.css -o output/static/css/tailwind.purged.min.css" },
-
pip install pelican[markdown]
-
pip install pelican-seo
-
pelican-quickstart
-
Put a theme in
./themes/mynewtheme/
and setTHEME = themes/mynewtheme
inpelicanconf.py
-
Create content
-
make html
ormake publish
(generate non-production or production version of the site) -
NODE_ENV=production npm run build
(generate a minified and purged tailwind.purged.min.css)
I have created a plugin that should make your life easier.
Let me know if you have some feedback 😉
https://github.com/pelican-plugins/tailwindcss