-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathknip.config.ts
More file actions
61 lines (58 loc) · 1.97 KB
/
Copy pathknip.config.ts
File metadata and controls
61 lines (58 loc) · 1.97 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
import type { KnipConfig } from "knip";
const config = async (): Promise<KnipConfig> => {
const isProduction = process.argv.includes("--production");
return {
tags: ["@knip-ignore", "@knip-public"],
/**
* @ref https://knip.dev/reference/configuration#paths
*/
paths: {
// Provide types for WXT's auto-imported modules
"#imports": [".wxt/types/imports-module.d.ts"],
},
...(isProduction && {
// In production mode, bundled JS files cannot trace original imports,
// so we exclude dependency-related checks
exclude: [
"dependencies",
"devDependencies",
"optionalPeerDependencies",
"binaries",
],
}),
/**
* @ref https://knip.dev/reference/configuration#entry
*/
entry: isProduction
? [
// Production mode: Built output (use with --production flag)
".output/*-mv*-production/background.js!",
".output/*-mv*-production/youtube-mainworld.js!",
".output/*-mv*-production/content-scripts/youtube.js!",
".output/*-mv*-production/chunks/*.js!", // FIXME2: FIXME1と同じくhtmlから検出できないため、仕方なくchunks配下を固定参照している。
// ".output/*-mv*-production/options.html!",
]
: [
// Development mode: WXT entrypoints
"src/entrypoints/*/index.{ts,tsx}",
"src/entrypoints/options/mount.tsx", // FIXME1: knipのcompilerがhtmlの<script src>から検出ができないらしいので、仕方なくオプションページのjsを固定参照している。本来はoptions/index.htmlから検出してほしい。
],
/**
* @ref https://knip.dev/reference/configuration#project
* @ref https://knip.dev/features/production-mode
*/
project: isProduction
? [
// Production mode: Built output
".output/*-mv*-production/**/*.{js}!",
]
: [
// Development mode: All source files
"src/**/*.{ts,tsx}",
],
ignoreBinaries: [
"gh", // GitHub CLI - external dependency not in package.json
],
};
};
export default config;