-
Notifications
You must be signed in to change notification settings - Fork 185
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
Exclude test files from glob pattern #662
Conversation
✅ Live Preview ready!
|
This is a very good issue - thanks for pointing it out. I feel this change may make the provided options more complex for developers and it gets used in their configuration. The module does provide an option to provide Do you think that maybe adding a separate glob string to the list may be useful? Something like: `!${srcDir}/**/*.{spec,test}.*` // mind the ! at the start |
I prefer your solution @ineshbose Happy to update your PR @maartenvanhunsel ? |
@ineshbose @atinux sorry for late response, just came back from a weekend trip. Yea sure, the solution you @ineshbose provided is way more clean and readable. @atinux just updated the docs. |
Will make a release once we fix the tests |
@atinux @ineshbose just had time to test if the error still occurred and unfortunately it is. See reproduction with updated Nuxt tailwind version: https://stackblitz.com/edit/github-huekcx-ch2uja?file=nuxt.config.ts Any thoughts? |
@maartenvanhunsel thanks for reporting back; I did have minor hesitations with that, and your new glob seems to be working better. So if we generalise it to other directories and extensions, would this work? (Stackblitz is acting weird for me to test changes) `${srcDir}/**/!(*.{test,spec}).*` Please feel free to open a new PR btw! |
@ineshbose I've already tested a lot of glob patterns but couldn't make it work with the exclude glob pattern. |
Oh, you meant that the glob is a modification to the first string rather than appending. Let's investigate further then! |
You're very right. I'm unable to think of how to solve this without modifying the existing content paths - but then they may get complicated. The added glob is not really helping (and in my case seems to be increasing the load for JIT). Moreover, there are also more cases like My thinking is to put the configuration to be done by developers in this case (since the module already provides content overriding option) and modify the documentation for it with an example for this; because there may be many ways that developers organise their test files (like if it were in a export default {
content (contentDefaults) {
return [
...contentDefaults,
// contentDefaults.map(c => c.endsWith('/**/*.{vue,js,ts}') ? c..replace('/**/*.{vue,js,ts}', '/**/!(*.{test,spec}).{vue,js,ts}') : c),
contentDefaults[0].replace('/**/*.{vue,js,ts}', '/**/!(*.{test,spec}).{vue,js,ts}'),
]
}
} What do you say @maartenvanhunsel ? While I'd love the module to consider ignoring tests out the box, it may be counter-intuitive for maintainability (although Atinux is the one who will call the shots 😄). Please do share if an ideal solution comes to mind. |
@ineshbose that's exactly my workaround I'm already using haha ;) This workaround is perfect to me, however it will take time to investigate for new people who encounter this errors because the logs are not very clear. |
Coming back to this PR after the content paths provided by the module are more dynamic and in-line with the nuxt.config, I wonder if we can add in https://nuxt.com/docs/api/nuxt-config#ignore globs to be ignored. |
See nuxt/nuxt#20404.