vite-require
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

vite-require

Like Webpack's require

NPM version NPM Downloads

English | 简体中文

dynamic-require similar to 👉 Webpack require('./foo/' + bar)

📦 Out of the box

🔨 Work only in the vite serve phase

Install

npm i vite-require -D

Usage

import { viteRequire } from 'vite-require'
export default {
  plugins: [
    viteRequire(/* options */)
  ]
}

API

viteRequire([options])

export interface Options {
  extensions?: string[]
  filter?: (id: string) => false | void
  dynamic?: {
    /**
     * 1. `true` - Match all possibilities as much as possible, More like `webpack`
     * 2. `false` - It behaves more like `@rollup/plugin-dynamic-import-vars`
     * @default true
     */
    loose?: boolean
  }
}

Package Sidebar

Install

npm i vite-require

Weekly Downloads

5,516

Version

0.2.3

License

MIT

Unpacked Size

30.5 kB

Total Files

14

Last publish

Collaborators

  • younglei
  • caoxie