vite-plugin-off-line-data
v0.2.3
Published
A Vite plugin.
Downloads
20
Readme
vite-plugin-off-line-data
A Vite plugin.
Installation
npm install vite-plugin-off-line-data
use
vite.config.js
import vitePluginOffLineData from 'vite-plugin-off-line-data';
export default {
...
plugins: [
vitePluginOffLineData({
outDir: 'mock', //
ignoreParameter: true, // ignore url param [Boolean | Function | Array]
include: ['/api', '/api1/v1'], // [(url)=>Boolean | Array | String]
requestPayload: {
'/api/v1/request1': 'arg1',
'/api/v1/request2': ['arg1', 'arg2', 'arg3'],
'/api/v1/request3': []
},
mode: 'read', // record | read
autoNext: false
})
]
}
Mock Data
eg: /api/v1/request/[method].[json | js]
{ contentType? : default = 'application/json' contentEncoding? contentDisposition? transferEncoding? statusCode? : default = 200 body? : json | string bodyPath? stream? : Boolean }
js
module.exports = function({ payload }){ return { body: 'eg' } }