Skip to content
PluginStats

mock-service-plugin weekly downloads statistics

By bianliuzhu · npm · Webpack plugins

Simulated backend interface service

View on npm Stale · Oct 18, 2026

mock-service-plugin has 11 recorded weekly downloads on npm, a decrease of 78.8% over the past 30 days, ranking #2038 of 2,322 tracked listings.

Weekly downloads
11
Official API · Oct 18, 2026
7-day growth
-95.5%
-233 weekly downloads
30-day growth
-78.8%
-41 weekly downloads
90-day growth
+267%
+8 weekly downloads
Rank
#2038
Among tracked npm listings

About mock-service-plugin

mock-service-plugin

English | 中文

A powerful local Mock service plugin that supports Webpack, Vite, and other mainstream build tools — letting you develop and debug frontend pages even before the backend APIs are ready.

Table of Contents


What is Mocking?

In real-world development, frontend and backend teams often work in parallel. When the backend APIs aren't ready yet, the frontend has no data to work with and development stalls.

Mocking means running a fake backend service locally that returns dummy data according to the agreed API contract, so frontend development can proceed independently without relying on a real backend.

What mock-service-plugin does is: read your mock data files, automatically start a local HTTP server, and return the corresponding data when frontend requests come in.


Features

  • 🚀 Supports multiple build tools: Webpack 4/5, Vite, Vue CLI, Create React App
  • 🎯 Compatible with Vue, React, and other mainstream frameworks
  • 🔥 Feature-rich
    • RESTful API support (GET / POST / PUT / DELETE, etc.)
    • Dynamic route parameters (e.g. /api/users/:id)
    • Streaming responses (SSE / EventStream, simulates AI typewriter effect)
    • Multiple response formats (JSON / XML / CSV / Image / Plain text, etc.)
  • 💡 Minimal configuration, hot reload, built-in debug interface

Installation

# npm
npm install mock-service-plugin --save-dev

# yarn
yarn add mock-service-plugin --dev

# pnpm
pnpm add mock-service-plugin --save-dev

5-Minute Quick Start

The following uses a Vite + Vue project as an example to walk you through your first Mock API from scratch.

Step 1: Install the Plugin
npm install mock-service-plugin --save-dev
Step 2: Create the Mock Directory and File

Create a mocks folder in the project root and add a file mocks/user.json:

project-root/
├── mocks/
│   └── user.json   ← create this file
├── src/
├── vite.config.ts
└── package.json

Contents of mocks/user.json:

/**
 * @url /api/user/info
 * @method GET
 */
{
  "code": 200,
  "data": {
    "id": "@id",
    "name": "@cname",
    "email": "@email",
    "avatar": "@image('100x100')"
  },
  "message": "success"
}

The /** ... */ comment at the top is the route configuration, telling the plugin which API path and HTTP method this file corresponds to.
@cname, @email, etc. are MockJS random data placeholders — each request generates different random data. See MockJS Syntax Reference for full syntax.

Step 3: Start the Mock Service in Vite

Create vite-mock-plugin.ts in the project root:

// vite-mock-plugin.ts
import { startServer } from "mock-service-plugin";
import { createServer } from "net";
import { join } from "path";

// Check if a port is already in use
function isPortTaken(port: number): Promise<boolean> {
  return new Promise((resolve) => {
    const server = createServer();
    server.once("error", (err: { code: string }) => {
      resolve(err.code === "EADDRINUSE");
    });
    server.once("listening", () => {
      server.close();
      resolve(false);
    });
    server.listen(port);
  });
}

// Vite plugin: start Mock service in mock mode
export default function ViteMockServicePlugin(mode: string) {
  return {
    name: "ViteMockServicePlugin",
    buildStart() {
      (async () => {
        const port = 3008;
        if (await isPortTaken(port)) {
          console.log(`[Mock] Port ${port} is already in use, skipping start`);
          return;
        }
        if (mode === "mock") {
          startServer({
            mockDir: join(__dirname, "./mocks"), // path to mock folder
            port, // mock service port
          });
        }
      })();
    },
  };
}

Update vite.config.ts:

// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import ViteMockServicePlugin from "./vite-mock-plugin";

export default defineConfig(({ mode }) => ({
  plugins: [
    vue(),
    ViteMockServicePlugin(mode), // pass current mode
  ],
  server: {
    proxy: {
      // Proxy /api requests to the mock service
      "/api": {
        target: "http://localhost:3008",
        changeOrigin: true,
      },
    },
  },
}));

Add a mock start script to package.json:

{
  "scripts": {
    "dev": "vite --mode dev",
    "mock": "vite --mode mock"
  }
}
Step 4: Start and Test
npm run mock

After starting, open http://localhost:3008/api/user/info in your browser and you'll see randomly generated user data:

{
  "code": 200,
  "data": {
    "id": "660000198812040277",
    "name": "Han Lei",
    "email": "c.wjjdmpyy@wfomlb.net",
    "avatar": "http://dummyimage.com/100x100"
  },
  "message": "success"
}

Congratulations! You've successfully set up your first Mock API. 🎉


Mock File Specification

File Structure

Each mock file consists of two parts:

file = top comment (route config) + response body
/**
 * @url /api/users        ← required: API path
 * @method GET            ← optional: HTTP method, defaults to GET
 */
{
  "code": 200,
  "data": []
}
Annotation Reference…

Description from the npm listing.

  • mock
  • mockjs
  • webpack-plugin
  • mock service
  • json server

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

mock-service-plugin weekly downloads on npm, last 90 days: 11 weekly downloads as of Oct 18, 2026, +267% over 90 days.mock-service-pluginWeekly downloads on npm · Last 90 days11downloads / week+267% over 90 days050100150200250Jul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 23, 2026 – Oct 18, 2026 · 88 observations · Updated Oc…pluginstats.com
mock-service-plugin weekly downloads on npm, last 90 days: 11 weekly downloads as of Oct 18, 2026, +267% over 90 days.

7/30/90-day growth

mock-service-plugin weekly downloads growth on npm: -95.5% over 7 days, -78.8% over 30 days, +267% over 90 days.mock-service-pluginWeekly downloads growth on npm11downloads / week now7-day growth-233 weekly downloads-95.5%30-day growth-41 weekly downloads-78.8%90-day growth+8 weekly downloads+267%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
mock-service-plugin weekly downloads growth on npm: -95.5% over 7 days, -78.8% over 30 days, +267% over 90 days.

Ranking history

mock-service-plugin npm ranking history: currently #2038 (by weekly downloads).mock-service-pluginnpm ranking · by weekly downloads · Last 90 days#2038current rank#1850#1900#1950#2000#2050Jul 22Aug 6Aug 21Sep 5Sep 20Oct 5Oct 20rankOct 18, 2026 – Oct 20, 2026 · 3 observations · Updated Oct 18, 2026pluginstats.com
mock-service-plugin npm ranking history: currently #2038 (by weekly downloads).

Listing placement

All npm2,320 listings · 116 pages · 1,162 shown · page 103, #2 (overall #2,042)
All npm: every listing in weekly downloads order

Listing placement

Webpack plugins251 listings · 13 pages · page 11, #12 (overall #212)
Webpack plugins: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (122)
Recent weekly downloads observations for mock-service-plugin
Date (UTC)Weekly downloadsChange vs. previous
11-4
15-16
31-170
201-1
202-2
2040
204-40
244+5
239+15
224+175
49+1
48+1
470
47—

Similar npm Webpack plugins plugins

All 20 mock-service-plugin alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/mock-service-plugin. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.