question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile CSS takes over 5 seconds using TailwindCSS + Sass

See original GitHub issue

Bug report

Describe the bug

I’m using TailwindCSS + Sass for my personal site and I noticed a slowness to compile when I do any change on the sass file.

So I added a Date.now() logs on the compiler and I got that on average it takes 5 seconds to compile. Worth to mention that my sass file is fairly small, the major part is to import tailwind.

Here’s the file https://github.com/maxigimenez/personal/blob/master/styles/index.scss

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Clone https://github.com/maxigimenez/personal
  2. Run the project locally
  3. Do any change on the styles.index.scss
  4. See error

Expected behavior

It should be faster IMO, mostly because this sass file could grow a lot for a larger project.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS
  • Browser (if applies) -
  • Version of Next.js: 9.4.4 (and also try it on canary)
  • Version of Node.js: 10.16.3

Additional context

These are the changes that I did to get the timing:

Screen Shot 2020-05-28 at 11 33 51 AM

Also, I’m more than open to investigate if you guys consider that this needs to be improved.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

23reactions
benbendercommented, Aug 1, 2020

@pavan-sagar Simply create two css files. First one has the global stuff (in my case font-imports, @tailwind base, etc) and the second one your app-specific css-stuff incl. @apply-rules.

Import both files in your _app.[j|t]sx. This way postcss will only rebuild the second file on changes and the rebuild is nearly instant, because it doesn’t need to reprocess all the tailwind-stuff.

5reactions
leerobcommented, Mar 17, 2021

I would highly recommend checking out Tailwind JIT, which solves this problem 😄

https://github.com/tailwindlabs/tailwindcss-jit

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimizing for Production - Tailwind CSS
Tailwind CSS is incredibly performance focused and aims to produce the smallest CSS file possible by only generating the CSS you are actually...
Read more >
Solve slow webpack compilation when using Tailwind @apply
Means every time I made change on the CSS, I have to wait 5 seconds to see the output, and multiply it with...
Read more >
Compile CSS On-demand with the Latest Tailwind Compiler
Lightning-fast build times. Tailwind typically takes 3 to 8 seconds to initially compile a project using the CLI and more than 30 to...
Read more >
CSS Auto hide elements after 5 seconds - Stack Overflow
Therefore, create an animation for the elements in question, and simply toggle visibility:hidden; after 5 seconds, whilst also setting ...
Read more >
Tailwind in 100 Seconds - YouTube
Tailwind is a utility-first CSS framework for building websites. It takes a functional approach to web design by providing thousands of tiny ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found