1.0.3 • Published 3 years ago

@col0ring/vite-plugin-mock v1.0.3

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Vite-Plugin-Mock

Install

npm install @col0ring/vite-plugin-mock -D
# or
yarn add @col0ring/vite-plugin-mock -D

Usage

import { defineConfig } from 'vite'
import path from 'path'
import viteMockPlugin from '@col0ring/vite-plugin-mock'

function resolve(relativePath) {
  return path.resolve(__dirname, relativePath)
}

export default defineConfig({
  plugins: [
    // ...
    viteMockPlugin({
      dir: resolve('./mock')
      // or multiple dirs
      // dir: [resolve('./mock'),resolve('./mock2')]
    })
  ]
})

Options

dir

  • Type: string | string[]

The directory you want to watch.

mockPrefix

  • Type: string
  • Default: /mock

Path prefix for all mock requests.

include

  • Type: RegExp | ((filename: string) => boolean)
  • Default: 'node_modules'

A RegExp or a filter function, to include when loading files.

exclude

  • Type: RegExp | ((filename: string) => boolean)
  • Default: 'node_modules'

A RegExp or a filter function, to exclude when loading files.