Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
vite-plugin-mock-dev-server
Advanced tools
Vite Plugin for API mock dev server.
.[cm]?js
/ .ts
/ .json
/ .json5
.mockjs
, or do not use it.text/json/buffer/stream
.server.proxy
viteConfig.define
and env
in the mock file.viteConfig.resolve.alias
in the mock file.vite preview
mode.multipart
content-type, mock upload file.WebSocket Mock
See the documentation for more details.
# npm
npm i -D vite-plugin-mock-dev-server
# yarn
yarn add vite-plugin-mock-dev-server
# pnpm
pnpm add -D vite-plugin-mock-dev-server
vite.config.ts
import { defineConfig } from 'vite'
import mockDevServerPlugin from 'vite-plugin-mock-dev-server'
export default defineConfig({
plugins: [
mockDevServerPlugin(/* plugin options */),
],
// The fields defined here can also be used in mock.
define: {},
server: {
// plugin will read `server.proxy`
proxy: {
'^/api': { target: 'http://example.com' }
}
}
})
The plugin will read the configuration of server.proxy
or options.prefix
, and enable mock matching for matched URLs.
The plugin will also read the define
configuration, which supports direct use in mock files.
By default, write mock data in the mock
directory of your project's root directory:
mock/**/*.mock.ts
:
import { defineMock } from 'vite-plugin-mock-dev-server'
export default defineMock({
url: '/api/test',
body: { a: 1, b: 2 }
})
The plugin is licensed under the MIT License
FAQs
Vite Plugin for API mock dev server.
The npm package vite-plugin-mock-dev-server receives a total of 2,193 weekly downloads. As such, vite-plugin-mock-dev-server popularity was classified as popular.
We found that vite-plugin-mock-dev-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.