0.0.4 • Published 6 months ago

vite-plugin-auto-modules v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

vite-plugin-auto-modules

npm version npm downloads bundle JSDocs License

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
}

License

MIT License © 2023-PRESENT Cyole

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago