From c8aeee941a6f257f1776bf8b18a2f1321bf83457 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Fri, 10 May 2024 14:53:05 +0100 Subject: [PATCH] Only scan src in client directory for Tailwind to prevent unnecessary rebuilds https://tailwindcss.com/docs/content-configuration#styles-rebuild-in-an-infinite-loop This speeds up the FE production build from 60s to ~21s on my machine, and also speeds up hot rebuilds to just ~3s --- CHANGELOG.txt | 1 + docs/releases/6.2.md | 1 + tailwind.config.js | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 638709640d..475ca24597 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,6 +16,7 @@ Changelog * Docs: Document Wagtail's bug bounty policy (Jake Howard) * Maintenance: Use `DjangoJSONEncoder` instead of custom `LazyStringEncoder` to serialize Draftail config (Sage Abdullah) * Maintenance: Refactor image chooser pagination to check `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` at runtime (Matt Westcott) + * Maintenance: Exclude the `client/scss` directory in Tailwind content config to speed up CSS compilation (Sage Abdullah) 6.1.1 (xx.xx.xxxx) - IN DEVELOPMENT diff --git a/docs/releases/6.2.md b/docs/releases/6.2.md index a412bb49a4..4547f6b059 100644 --- a/docs/releases/6.2.md +++ b/docs/releases/6.2.md @@ -37,6 +37,7 @@ depth: 1 * Use `DjangoJSONEncoder` instead of custom `LazyStringEncoder` to serialize Draftail config (Sage Abdullah) * Refactor image chooser pagination to check `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` at runtime (Matt Westcott) + * Exclude the `client/scss` directory in Tailwind content config to speed up CSS compilation (Sage Abdullah) ## Upgrade considerations - changes affecting all projects diff --git a/tailwind.config.js b/tailwind.config.js index 45473dedaf..99bcd76569 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -8,7 +8,12 @@ module.exports = { content: [ './wagtail/**/*.{py,html,ts,tsx}', './wagtail/**/static_src/**/*.js', - './client/**/*.{js,ts,tsx,mdx}', + // Make sure NOT to include the `client/scss` directory, + // even if we don't specify `*.scss` files here. + // The directory would still be scanned for files, which would cause + // the styles to rebuild in a loop. + // https://tailwindcss.com/docs/content-configuration#styles-rebuild-in-an-infinite-loop + './client/src/**/*.{js,ts,tsx,mdx}', './docs/**/*.{md,rst}', ], corePlugins: {