tailwindlabs / tailwindcss-jit

MIT License
2.19k stars 40 forks source link

Add TAILWIND_TOUCH_ROOT env var for custom touch dir #152

Closed chickencoder closed 3 years ago

chickencoder commented 3 years ago

This PR adds the ability to specify a custom root path for .tailwindcss touch files directory. This will enable special environments with file system restrictions (like serverless environments) to be able to configure where these touch files are written to.

I believe an option like this will be needed if the Tailwind Play project is updated to use JIT since it's deployed to Vercel. Vercel serverless functions can only write to the /tmp directory but in most other environments it makes most sense to put touch files in the $HOME directory.

adamwathan commented 3 years ago

Bravo for even figuring out what was going on with this crap 😅 This looks good to me from what I understand but going to tag @bradlc for his opinion too!

bradlc commented 3 years ago

Seems like a good idea! I would be tempted to use the env variable as the full path if it's defined, something like this:

const touchDir = process.env.TAILWIND_TOUCH_DIR || path.join(os.homedir() || os.tmpdir(), '.tailwindcss', 'touch')

This would give you more control over the exact path. What do you think?

chickencoder commented 3 years ago

I agree that would be more flexible! Makes sense as long as there's no reason to preserve the '.tailwindcss' convention?

bradlc commented 3 years ago

I agree that would be more flexible! Makes sense as long as there's no reason to preserve the '.tailwindcss' convention?

No, I don't think there's any reason to keep that if you are manually specifying a custom directory 👍

adamwathan commented 3 years ago

Thanks will get this out in a release soon! Hopefully we can just stop doing this crap altogether at some point 🥴