A simple PostCSS plugin designed to cover all of the tricky integration points a build-tool needs to support for Tailwind CSS.
This is a simple PostCSS plugin designed to cover all of the tricky integration points needed for a tool like Tailwind to work.
The idea here is that if we can successfully port this plugin to an SWC CSS plugin, it will prove that everything we need to offer Tailwind as an SWC plugin exists.
This includes things like:
@tailwind
in the CSS and replacing them with our own generated CSSWe've deliberately left out anything that is repetitive or low-risk as we don't need any help in those areas.
npm install
We've included tests for much of this behavior in ./index.test.js
, which you can run using the test
script:
npm install
These tests cover all of the important transformations we need to be able to support, but exclude the behavior around when to trigger rebuilds as that is easier to capture with a demo project.
There's a demo project in ./watching-demo
designed to test all of the scenarios that should trigger the CSS to be rebuilt.
You can run this demo by running the demo
script from the project root:
npm run demo
This starts a small webpack project that is configured to use this PostCSS plugin. It will trigger a rebuild in the following situations:
tailwind.config.js
file has changed.content
section of the tailwind.config.js
file have changed.content
section of the tailwind.config.js
file.We recommend opening ./watching-demo/dist/main.css
in a separate window so you can see that file being rebuilt any time you make any of the changes outlined above.