Don’t cache .css files in Tailwind projects #3326
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #3041, #3246
Changes
2021-05-19.18-55-25.2021-05-19.18_55_59.mp4
Our dev server aggressively caches builds, which is good for HMR but is really hard for making Tailwind usable.
Problem
In the server, we can see that an
.html
or.js
file changed, and send the necessary HMR response, either to reload the page, or clear the cache, or both. But with Tailwind,index.html
is the file that changes, butglobal.css
is the file that needs the HMR response / cache bust.There’s currently no link between these files, at least as far as the dev server is aware. To fix this, we’d have to a) scan
index.html
contents and see, or b) build some dependency graph, or c) conditionally change caching behavior based on whether Tailwind is present or not.This PR
In Tailwind projects only,
.css
files are not cached in the dev server. This lets Tailwind handle when they are rebuilt, and not Snowpack.This PR adds a
devOptions.tailwindConfig
option to enable / disable Tailwind. This saves us from having to scan for Tailwind presence/absense and instead lets the user tell us.Testing
Manually tested; not easy to write a test for this
Docs
Added
devOptions.tailwindConfig
as a config option, added docs.