Skip to content

PostCss-A marvel by Kuldeep

December 18, 2022 | 12:00 AM

PostCss

PostCSS: A tool for transforming CSS with JavaScript

But why?

To install on Astro

npm i -D postcss autoprefixer open-props postcss-jit-props postcss-nested

include any other plugin you want to add.

Then add postcss.config.js file in folder root with these settings

const postcssjitprops = require("postcss-jit-props");
const OpenProps = require("open-props");


module.exports = {
  plugins: [
    postcssjitprops(OpenProps),
    require('postcss-nested'),
    require('autoprefixer'),
  ]
};

Add these line to package.json for autoprefixer

"browserslist": [
     "defaults"
 ]

To install on Nextjs

As of now postcss-jit-props doesn’t work on Nextjs

npm i -D open-props

Install any other plugin you want to use through npm

import indivisual package in global css file as required

@import "open-props/sizes";
@import "open-props/colors";
@import "open-props/fonts";
@import "open-props/gradients";

Check Open-props website for more


Tip: Use sass with open-props

To install on Vite

npm i -D open-props postcss-jit-props

Include any other plugin you want to add.

Then add postcss.config.js file in folder root with these settings

const postcssJitProps = require('postcss-jit-props');
const OpenProps = require('open-props');

module.exports = {
  plugins: [postcssJitProps(OpenProps)],
};