-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathknip.config.ts
More file actions
72 lines (63 loc) · 2.66 KB
/
knip.config.ts
File metadata and controls
72 lines (63 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import type { KnipConfig } from 'knip';
import { parse } from 'vue/compiler-sfc';
const config: KnipConfig = {
// Custom Vue SFC compiler using the real vue/compiler-sfc parser.
// Fixes a Knip limitation: <script setup> components have an implicit
// default export that Knip's built-in regex compiler doesn't see.
// Without the synthetic `export default {}`, --trace and --trace-file
// return empty results for Composition API components.
compilers: {
vue: (text: string) => {
const { descriptor } = parse(text, { sourceMap: false });
const scripts = descriptor.scriptSetup?.content ?? '';
const script = descriptor.script?.content ?? '';
const styles = descriptor.styles?.map(s => s.content).join('\n') ?? '';
// <script setup> creates an implicit default export that the
// raw content alone doesn't express. Add it so Knip can trace it.
const syntheticExport = descriptor.scriptSetup ? '\nexport default {};' : '';
return [scripts, script, syntheticExport, styles].join('\n');
},
},
// Entry points — where Knip starts tracing the dependency tree
entry: [
// Main app entry
'resources/js/app.ts',
// SSR entry
'resources/js/ssr.ts',
// Inertia pages — only actual page files, not shared sub-components
'resources/js/pages/**/*.vue',
'!resources/js/pages/**/_components/**',
'!resources/js/pages/**/Components/**',
],
// Files that are part of the project (what Knip should analyze)
project: [
'resources/js/**/*.{vue,ts,js,tsx}',
],
// Directories to completely ignore
ignore: [
// Build artifacts
'public/build/**',
// E2E tests (separate concern, not part of Vue dependency tree)
'e2e/**',
// shadcn UI components (vendored library, not all are used by design)
'resources/js/components/ui/**',
// Generated types (auto-generated, not manually maintained)
'resources/js/types/generated/**',
],
// Disable Vite plugin auto-detection of entry points — it picks up
// import.meta.glob('./pages/**/*.vue') from app.ts and adds ALL files
// (including _components/) as entry points, bypassing our negation.
vite: false,
// Ignore specific dependencies that are used implicitly
ignoreDependencies: [
// Tailwind v4 Vite plugin (loaded via vite config)
'@tailwindcss/vite',
// Vite plugins
'@vitejs/plugin-vue',
// Build tools
'husky',
// Type definitions
'@types/node',
],
};
export default config;