-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
Add UnoCSS plugin #638
Add UnoCSS plugin #638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hyoban! No modifications seem to have been made, any chance you could still customize or just remove things specifically tailored to UnoCSS?
Sorry. I don't quite understand what I need to modify, can you be more specific? I basically implemented the unocss plug-in according to the vite plug-in. |
@@ -0,0 +1,4 @@ | |||
export type PluginConfig = { | |||
plugins?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type doesn't seem correct?
@@ -0,0 +1,4 @@ | |||
export type PluginConfig = { | |||
plugins?: string[]; | |||
entryPathsOrPatterns?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this type does not exist in UnoCSS config
|
||
const entry: string[] = []; | ||
|
||
const production: string[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove empty arrays
|
||
const title = 'UnoCSS'; | ||
|
||
const enablers: EnablerPatterns = ['unocss', /^@unocss\//]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use only unocss
and @unocss/cli
for better precision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other dependencies to consider, such as @unocss/webpack
, @unocss/postcss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "enabling packages" should only be root/core modules. The rest is referenced elsewhere, in the tool configuration. The plugin returns those to Knip, and packages can then be reported as unlisted or unused.
Having more enablers is not wrong, I just think a smaller list is more precise/easier to understand for consumers. Otherwise we'd have to try and list all possible plugins/dependencies etc. in all plugins which doesn't really make sense imho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My previous understanding was wrong, it seems we only need ['unocss']
import { defineConfig } from 'unocss' | ||
|
||
export default defineConfig({ | ||
// ...UnoCSS options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to use a more comprehensive config file here to make it more real-world.
Thank you for your review. Sorry, I thought the default code generated from CLI could be left alone. Another question, can the plug-in tell Knip to ignore some dependencies that it thinks do not exist when using UnoCSS? For example |
No worries! Thanks for contributing to Knip, I really appreciate it.
No, but specifiers starting with If |
And we need to set I added a test that will fail in |
Sorry, I was wrong about this, they're not ignored. Here's what happened: #370
Yes, that's currently how it works indeed.
There's two options (I don't mind which one):
|
Thanks @hyoban! |
🚀 This pull request is included in v5.17.0-canary.0. See Release 5.17.0-canary.0 for release notes. Using Knip in a commercial project? Please consider sponsoring me. |
No description provided.