Skip to content

sc834466168/vite-require

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  }
}

About

Like Webpack's require

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 88.7%
  • JavaScript 9.8%
  • HTML 1.5%