Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/rstack/src/fmt/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ const fingerprintPlugin = async (
return undefined;
}

// Tailwind sorting can depend on stylesheets and auto-discovered configs,
// including their transitive dependencies, which our cache does not track.
if (pkg.name === 'prettier-plugin-tailwindcss') {
return undefined;
}

return JSON.stringify([
'package',
pkg.name,
Expand Down
40 changes: 40 additions & 0 deletions packages/rstack/tests/cli/fmt/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,46 @@ test('--no-cache bypasses cache reads and writes', () => {
expect(projectFileExists('.rstack/cache/.gitignore')).toBe(false);
});

test('bypasses the cache for files using the Tailwind plugin', () => {
writeProjectFile(
'rstack.config.ts',
`import { define } from 'rstack';

define.fmt({
overrides: [{
files: '*.html',
options: {
plugins: ['prettier-plugin-tailwindcss'],
tailwindStylesheet: ${JSON.stringify(resolveProjectPath('app.css'))},
},
}],
});
`,
);
writeProjectFile('index.html', '<div class="alpha beta"></div>\n');
writeProjectFile('index.ts', 'const value = 1;\n');
writeProjectFile(
'app.css',
'@utility alpha { display: flex; }\n@utility beta { padding: 1rem; }\n',
);

expect(runFmt(['--check', 'index.html', 'index.ts']).status).toBe(0);

writeProjectFile(
'app.css',
'@utility alpha { padding: 1rem; }\n@utility beta { display: flex; }\n',
);
expect(runFmt(['--check', 'index.html']).status).toBe(1);
expect(runFmt(['index.html']).status).toBe(0);
expect(readProjectFile('index.html')).toBe(
'<div class="beta alpha"></div>\n',
);
expectSingleCleanEntry(
readFmtCache('.rstack/cache/fmt/cache.json'),
'index.ts',
);
});

test.each(['relative', 'absolute'] as const)(
'uses a %s custom cache location',
(kind) => {
Expand Down
Loading