2023-03-23 22:08:59 +01:00
|
|
|
import sveltePreprocess from 'svelte-preprocess'
|
|
|
|
import { preprocess, compile } from 'svelte/compiler'
|
|
|
|
import type { KnipConfig } from 'knip'
|
|
|
|
|
|
|
|
const sveltePreprocessor = sveltePreprocess()
|
|
|
|
|
|
|
|
const config: KnipConfig = {
|
2023-03-24 20:18:16 -04:00
|
|
|
ignore: ['**/*.d.ts'],
|
2023-03-23 22:08:59 +01:00
|
|
|
paths: {
|
|
|
|
// This ain't pretty, but Svelte basically does the same
|
|
|
|
'$app/*': ['node_modules/@sveltejs/kit/src/runtime/app/*'],
|
2023-03-24 12:20:29 +01:00
|
|
|
'$env/*': ['.svelte-kit/ambient.d.ts'],
|
2023-03-23 22:08:59 +01:00
|
|
|
'$lib/*': ['src/lib/*'],
|
|
|
|
},
|
|
|
|
compilers: {
|
|
|
|
svelte: async (text: string) => {
|
|
|
|
const processed = await preprocess(text, sveltePreprocessor, { filename: 'dummy.ts' })
|
|
|
|
const compiled = compile(processed.code)
|
|
|
|
return compiled.js.code
|
|
|
|
},
|
|
|
|
css: (text: string) => [...text.matchAll(/(?<=@)import[^;]+/g)].join('\n'),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default config
|