I am trying to use scss but tailwind is not compiling as expected.
Thats how i build application.css
"build:css": "tailwindcss -i ./app/assets/stylesheets/application.scss -o ./app/assets/builds/application.css"
Here is my application.scss;
@import 'application_dock/colors.scss';
@import 'application_dock/pages/spots.scss';
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
font-family: 'Noto Sans';
background-color: var(--bg-color);
}
Spots.scss;
.spots {
.spot {
color: blue;
.spot-content {
@apply h-32;
}
}
}
And here is the built css file output;
.spots {
.spot {
color: blue;
.spot-content{
height: 8rem;
}
}
}
I expect it to be like;
.spots .spot {
color: blue;
}
.spots .spot .spot-content {
height: 8rem;
}
My postcss.config.js;
module.exports = {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {}
},
}
2
Answers
After installing
postcss-cli
and building withpostcss
fixed the issue/Feels like an unspoken configuration:
Just update
package.json
and add--postcss
option, it also takes an optional path to postcss.config.js:Also, consider making a spot helper/component/partial and avoid extra css and unnecessary nesting:
Literally spent 10 minutes playing with spots: