New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JIT] Purge paths with 'parent' levels (../
) not working with JIT when symlinked
#4059
Comments
Im noticing the same issue |
../
) not working with JIT../
) not working with JIT
The same issue in a monorepo using |
I realized something. |
any update on this? |
Haven't looked at it yet. Feel free to PR a fix if you like 👍🏻 |
@adamwathan appreciate the response, happy to take a look see if i can figure it out. Do you have any suggestion of where/what file to start looking at? |
https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/purgeUnusedStyles.js I'm going to assume right here! |
After digging into this a bit today, I've determined that it's actually an issue related to symlinking the tailwind root folder into my project. Tailwind (or perhaps even postcss) is resolving the symlink and therefore the purge entries that are going 'up' (i.e. Example: I have a tailwind theme in my web project:
This is where tailwind is located, and this is where I run However, that
With my purge configuration:
The first entry is going up two levels, so instead of looking for purge files in the correct path of I'm not sure how/why this works with the non-JIT 'purge' process, but with JIT it's definitely purging differently. |
../
) not working with JIT../
) not working with JIT when symlinked
I have found a workaround that is very hackish but works for our use case, maybe this can help pin-point how/if this can be resolved within JIT. The main problem seems to be caused by the path being relative to the symbolically linked folder rather than project location it is residing in. I tried several ways within JIT to get the path relative to the project linked to ( This is my workaround within the const path = require('path');
const process = require('process');
const dirname = process.env.PWD || process.cwd();
const normalize = (paths) => {
return paths.map((_path) => path.normalize(`${dirname}/${_path}`));
}
module.exports = {
mode: 'jit',
purge: normalize([
'../../config/**/*.yaml',
'../../pages/**/*.md',
'./blueprints/**/*.yaml',
'./js/**/*.js',
'./templates/**/*.twig',
'./typhoon.yaml',
'./typhoon.php',
'./available-classes.md',
]),
Cheers, |
Just to confirm, @w00fz's approach addresses my issue. However, I've not closed this because the unexpected difference between non-JIT and JIT behavior leads me to believe this should still be addressed inside JIT so the behavior remains the same between the two. |
Thanks for digging into this! I expect this will be resolved when we merge #4214 👍🏻 |
Will be fixed in v2.2! In the mean time use the canary build if you want to test it out right away:
|
@adamwathan tailwind 2.2.0-canary was working for this issue up to version |
Should I create a new ticket or will you re-open this one? Cheers. |
I can confirm something got reverted after #4214 because we are back to square one and the relative pathing is still an issue. |
I believe this has been adjusted to what you want here: Try |
@adamwathan i tried the latest |
fwiw — I think this issue is not specific to symlinked setups. I'm running into this issue (I think) in a project where there are definitely no symlinks in play, and the Tailwind/Vite install is as vanilla as possible. In my project, Tailwind lives in (If, on the other hand, I move my source files below the working dir and ask Tailwind to purge |
What version of Tailwind CSS are you using?
2.1.1
What build tool (or framework if it abstracts the build tool) are you using?
postcss-cli v8.3.1
What version of Node.js are you using?
Node v12.20.1
What browser are you using?
Chrome
What operating system are you using?
macOS v11.2.3
Reproduction repository
https://cln.sh/Nwpa4g
Describe your issue
Prior to JIT, I was able to 'purge' paths for production CSS that included paths 'above' the current directory by using the standard filesystem
../
syntax. For example my purge setup is as follows:I'm working in a CMS where Tailwind is part of a theme in
user/themes/theme_name
folder. However, I also need to check any configuration inuser/config/**/*.yaml
as well as any references to Tailwind classes in content pages (user/pages/**/*.md
).This works fine in Tailwind without JIT enabled. However, as soon as JIT is enabled those
../*
paths are ignored.You can see this clearly in the linked video because changes in those files do not trigger a JIT compilation, whereas changes in the non-
../
paths do.The text was updated successfully, but these errors were encountered: