Closed gopeter closed 4 years ago
Same slow build times here. Related to other open issues: https://github.com/tailwindlabs/tailwindcss/discussions/1514 and https://github.com/JeffreyWay/laravel-mix/issues/2411
this kinda helped me: https://gist.github.com/Jossnaz/7cf182e794e515d068159ad71fcf7855
I use yarn hot
to build
tailwind is set to watch. And incremental watch builds seem to work
initial build time is still almost 30s or so. BUT: the tailwind build runs in a separate process, thus you are free to go coding right away.
basically concurrently or whatever the lib is called runs hot and watch in separate process
as well: tailwind is split into utilities and your own stuff that way you dont have to rebuild utilities on each change
so its 2 things that help DX 2 process split tailwind files
Same slow build times here.
By splitting Tailwind utilities from the rest of the stylesheet, i got down from 26 seconds on every file change to 0.15 seconds. You pretty much get instant feedback.
The initial build still takes 26 seconds because it needs to compile all of those thousands of lines of utility classes, but the subsequent builds a really fast and that's what matters.
Here's my setup
webpack.mix.js
const postCssPlugins = [
require("postcss-import")({
from: "resources/css/app.css"
}),
require("tailwindcss"),
require("postcss-preset-env")({
stage: 0
}),
];
mix
.postCss("resources/css/app.css", "public/css", postCssPlugins)
.postCss(
"resources/css/tailwind-utilities.css",
"public/css",
postCssPlugins
);
app.css
@import 'tailwindcss/base';
@import 'tailwindcss/components';
/* Custom components */
@import 'components/button';
tailwind-utilities.css
@import "tailwindcss/utilities";
app-layout.blade.php
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<link rel="stylesheet" href="{{ mix('css/tailwind-utilities.css') }}">
This works great. If you want just one compiled css file, you can use mix.combine
, but I like to keep them seperate β At least during development. It makes it a little easier if you don't have 20k lines of utility classes mixed in with your actual CSS.
Itβs hard to debug such a massive mix configuration file. To help, Iβd need you to break this down to the simplest reproducible example.
Also check Mix 6 beta. That may have resolved the issue inadvertently.
Description:
Initial compilation of my
app.css
takes 50-60 seconds, changes to it need around 40-50 seconds (even if I just press Save again). Removing the Tailwind directives in theapp.css
makes it fast again, but I thought that these would be incremental builds. Is there any misconfiguration on my side?Steps To Reproduce:
app.css
:And that's my
webpack.mix.js
file (based on https://github.com/ben-rogerson/agency-webpack-mix-config, but with a few changes):