Giter VIP home page Giter VIP logo

purge-per-route's Introduction

Tailwind Purge-Per-Route Demo

This is a demo for creating tailwind stylesheets for routes that purge based on the entire ancestry of the route.

Feel free to play with the live demo. To see the CSS splitting per route, open up your Network tab and hover/click on all the links!

Here is a video that explains what's going on and why it's so cool!

Purge-Per-Route Demo

How does it work

All of the magic is in scripts/styles.js

I tried to make the logic as clean as possible, but it's still a solid 500 lines and was built for a demo, so it might not be the most production ready code you've seen.

To help orient you around how the logic roughly works, here it is represented as a statechart (note: the actually logic is not an explicit statechart).

Statechart for generating stylesheets for a Remix app

Getting started

  • Install dependencies:

    npm run install
  • Start dev server:

    npm run dev

And you should be good to go!

How this project was developed

This project was started with the Indie Stack.

A lot of the bits have been removed, such as ƒly, prisma, and mocking and testing

To get started with the Indie stack on a separate project, simply run:

npx create-remix --template remix-run/indie-stack

Additionally, this demo leverages lots of free sample components/views from Tailwind UI: https://tailwindui.com/

Tailwind UI is a very cool paid product from Tailwind Labs (the company behind Tailwind CSS). Using Tailwind UI was the quickest way to add a bunch of tailwind classes to demonstrate the power behind the idea in this repository.

purge-per-route's People

Contributors

mehulcse avatar brookslybrand avatar

Stargazers

Danil Tankov avatar Roman avatar Adnan Ahmed avatar Matthias Kern avatar li.li avatar Mert Certel avatar Francois Bisschop avatar Amen avatar Michel avatar  avatar Benjamin avatar Ramin Rezaei avatar Matias H. Leidemer avatar Corentin Leruth avatar Florent avatar Your Solution Provider / Tech Engineer avatar Vitaly Tkachenko avatar Tobias Foerg avatar Fritz Blueford avatar Andrii Skrebets avatar Johan Liljegren avatar Nikita avatar Ludovic avatar JD Angerhofer avatar Logan McAnsh avatar

Watchers

James Cloos avatar  avatar

Forkers

elander mehulcse

purge-per-route's Issues

does it work for component inside node_modules?

let's say route A imports a component from node_modules

import { Button } from 'ui-lib';

and the component - Button relies on some atomic class. I guess those classes would be purged, right?

The component classNames not compiling inside route style file

Hi, thank you for building the great workaround.

I came across small details while testing things out. so, the classNames inside the component not being compile inside the routeName.css file, instead of compiling root.css file. I tried to reproduce this issue.

Created a tiny component and imported in the index.tsx file, i expected that the text-red-500 class name will be compiled in styles/index.tsx, not inside root.css. Am I missing something?

https://stackblitz.com/edit/node-lxyfa7?file=app%2Fcomponents%2FButton.tsx

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.