vite-plugin-dirs
v0.0.3
Published
A vite plugin to get the names of all files in a specified directory
Downloads
6
Maintainers
Readme
vite-plugin-dirs
A vite plugin to get the names of all files in a specified directory
const settled = import.meta.dirs('/src', { exhaustive: true })
// to
const settled = {
name: 'src',
type: 'dir',
children: [
{
name: 'main.ts',
type: 'file'
},
{
name: 'style.css',
type: 'file'
},
{
name: 'test',
type: 'dir',
children: [
{
name: 'test',
type: 'dir',
children: [
{
name: '1.ts',
type: 'file'
}
]
}
]
}
]
}
Install
npm i vite-plugin-dirs -D
Usage
import dirs from 'vite-plugin-dirs'
export default defineConfig({
// ...
plugins: [
dirs(),
],
// ...
})
Client Types
add vite-plugin-dirs/client to compilerOptions.types of your tsconfig:
{
"compilerOptions": {
"types": [
"vite-plugin-dirs/client"
]
}
}
Options
export interface DirsOptions {
/**
* exclude some files or directories, default: /^\.|node_modules/
* @default false
*/
exhaustive?: boolean | RegExp
}