-
Notifications
You must be signed in to change notification settings - Fork 210
How to add Tailwindcss to the Starter theme #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
To add Tailwind to the Starter theme: Install the dependenciesnpm install -D tailwindcss autoprefixer Create a Tailwind confignpx tailwindcss init Update the Tailwind config/** @type {import('tailwindcss').Config} */
export default {
theme: {
extend: {},
},
plugins: [],
content: [
"/*.hbs",
"./**/*.hbs",
]
} Update CSSInclude Tailwind base styles @tailwind base;
@tailwind components;
@tailwind utilities; Update Rollup config// Update the imports
import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';
// Update the postcss config
postcss({
extract: true,
plugins: [
tailwindcss,
autoprefixer
]
}), That should do it. |
I am running into a bit of a speed bump with this process. So far I have done the following:
Here is a video showing what I am seeing. |
Have you activated the theme from Ghost Admin? This isn't the best place for support, so if you still have trouble, I recommend coming over to the official Ghost Forum. We'll get you sorted! |
Thanks @royalfig for the guidance, I appreciate it. EDIT: from localhost:2368/ghost I had missed the step that required that I go into Settings > Design > Change Theme and activating the new TailwindCSS starter. |
Tailwind is not working with livereload I guess |
@rosu-catalin What are you experiencing exactly? This might be a bug with the postcss plugin. I'll do some more investigation and follow up. |
While I'm using rollup for live reload with Tailwind, it's kind of blocked in a reload loop, as you can see in the video below. |
I believe this is caused by a bug in the I'm trying to see if there's a workaround. |
After some experimentation, here's what I found to be the best way to use Tailwind here (given the bug in the postcss plugin). The solution is to use Tailwind's CLI tool alongside Rollup. Where Tailwind processes the CSS from HBS files, Rollup handles all the JS.
@tailwind base;
@tailwind components;
@tailwind utilities;
"dev": "concurrently \"rollup -c --environment BUILD:development -w\" \"npx tailwindcss -i ./assets/css/index.css -o ./assets/built/index.css --watch\" ",
"build": "rollup -c --environment BUILD:production && npx tailwindcss -i ./assets/css/index.css -o ./assets/built/index.css --minify",
|
Works now! Thanks a lot |
Thank you! This helped me get started and I was able to keep the existing styles by importing the tailwindcss declarations from example
|
Originally posted by @Isaac-Tait in #60 (comment)
The text was updated successfully, but these errors were encountered: