Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 1,457 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.