From 7efc95de4319d4f561de00d50c6a66ad7bff6216 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:39:06 +0100 Subject: [PATCH] fix(cli): Tailwind setup updates `scaffold.css` when needed (#9290) **Problem** The `yarn rw g scaffold ...` command does not update the styling when you have updated to tailwind with `yarn rw setup ui tailwindcss`. Fixes #4382 **Changes** 1. The `yarn rw setup ui tailwindcss` will now prompt to update an existing `scaffold.css`. --- .../setup/ui/libraries/tailwindcss.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/cli/src/commands/setup/ui/libraries/tailwindcss.js b/packages/cli/src/commands/setup/ui/libraries/tailwindcss.js index d7b1ce953817..40ed1a6273d7 100644 --- a/packages/cli/src/commands/setup/ui/libraries/tailwindcss.js +++ b/packages/cli/src/commands/setup/ui/libraries/tailwindcss.js @@ -242,6 +242,44 @@ export const handler = async ({ force, install }) => { } }, }, + { + title: "Updating tailwind 'scaffold.css'...", + skip: () => { + // Skip this step if the 'scaffold.css' file does not exist + return !fs.existsSync(path.join(rwPaths.web.src, 'scaffold.css')) + }, + task: async (_ctx, task) => { + const overrideScaffoldCss = + force || + (await task.prompt({ + type: 'Confirm', + message: + "Do you want to override your 'scaffold.css' to use tailwind too?", + })) + + if (overrideScaffoldCss) { + const tailwindScaffoldTemplate = fs.readFileSync( + path.join( + __dirname, + '..', + '..', + '..', + 'generate', + 'scaffold', + 'templates', + 'assets', + 'scaffold.tailwind.css.template' + ) + ) + fs.writeFileSync( + path.join(rwPaths.web.src, 'scaffold.css'), + tailwindScaffoldTemplate + ) + } else { + task.skip('Skipping scaffold.css override') + } + }, + }, { title: 'Adding recommended VS Code extensions to project settings...', task: (_ctx, task) => {