vite-plugin-auto-modules
v0.0.4
Published
Automatically use modules from a folder
Downloads
6
Maintainers
Readme
vite-plugin-auto-modules
A Vite plugin that automatically use modules from a folder.
Getting Started
Installation
pnpm install vite-plugin-auto-modules -D
Add to vite.config.ts
import { defineConfig } from 'vite'
import AutoModules from 'vite-plugin-auto-modules'
export default defineConfig({
plugins: [
AutoModules({
// options
})
]
})
Usage
main.ts
import { createApp } from 'vue'
import { installModules } from 'virtual:auto-modules'
import App from './App.vue'
const app = createApp(App)
// install modules
installModules(app)
app.mount('#app')
Place a .ts
file with the following template in the moduleDir
folder, it will be installed automatically.
import type { UserModule } from 'vite-plugin-auto-modules'
export const install: UserModule = (app) => {
// do something
}
Client Types
If you want to use the types of the client, you need to add the following configuration to tsconfig.json
.
{
"compilerOptions": {
"types": ["vite-plugin-auto-modules/client"]
}
}
Configuration
export interface Config {
/**
* @default "/src/modules"
*/
moduleDir?: string
}