Skip to content

Commit

Permalink
fix(cli): Tailwind setup updates scaffold.css when needed (#9290)
Browse files Browse the repository at this point in the history
**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`.
  • Loading branch information
Josh-Walker-GM authored and jtoar committed Oct 28, 2023
1 parent 3d58200 commit 7efc95d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/cli/src/commands/setup/ui/libraries/tailwindcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 7efc95d

Please sign in to comment.