npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unplugin-mockery

v0.3.17

Published

[![NPM version](https://img.shields.io/npm/v/unplugin-mockery)](https://www.npmjs.com/package/unplugin-mockery)

Downloads

316

Readme

unplugin-mockery

NPM version

Preview Usage Video

Features

  • Vue CLI (webpack)
  • Vite
  • Hot Reload Routes

Why unplugin-mockery?

  • A visual mock management devtool.
  • We have some old projects that need to be compatible with Vue CLI and Vite.

Install

pnpm add -D unplugin-mockery
// vite.config.ts
import Mocker from 'unplugin-mockery/vite'

export default defineConfig({
  plugins: [
    Mocker({ /* options */ }),
  ],
})

Example: playground/

// rollup.config.js
import Mocker from 'unplugin-mockery/rollup'

export default {
  plugins: [
    Mocker({ /* options */ }),
  ],
}

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-mockery/webpack').default({ /* options */ })
  ]
}

export default defineNuxtConfig({
  modules: [
    'unplugin-mockery/nuxt',
  ],

  unpluginMockery: {
    mockDir,
    client: {
      port: 51223,
    },
  },
})

在 Webpack 中,它工作地很好。 但在 Vue Cli 中,webpack-dev-server 的启动时机有所不同,因此我们无法通过插件获取 Vue Cli 中的 webpack-dev-server devServer 的实例。 而是通过获取 webpack 的方式进行设置。

In Webpack, it works well. But in Vue Cli, the timing of starting webpack-dev-server is different, so we cannot get the instance of webpack-dev-server devServer in Vue Cli through the plugin. Instead, we set it by getWebpackConfig.

// vue.config.js
const { getWebpackConfig } = require('unplugin-mockery/webpack')

module.exports = {
  configureWebpack: {
    devServer: {
      ...getWebpackConfig({ /* options */ }).devServer,
    },
  },
}
# .env custom client port
VUE_APP_MOCKERY_CLIENT_PORT=51224

// esbuild.config.js
import { build } from 'esbuild'
import Mocker from 'unplugin-mockery/esbuild'

build({
  plugins: [Mocker()],
})

Schema Setting in VSCode

Edit .vscode/settings.json:

{
  // schema
  "json.schemas": [
    {
      "fileMatch": ["*.scene.json"],
      "url": "./mock/schemas/scene.schema.json"
    }
  ]
}

Development

# run template

# for vue-cli(webpack)
pnpm play:vue-cli

# for webpack
pnpm play:webpack

# for vite
pnpm play:vite

Options

export interface Options {
  /**
   * Base URL for inspector UI
   *
   * @default read from Vite's config
   */
  base?: string

  // define your plugin options here
  /**
   * Display debug information.
   */
  debug?: boolean

  /**
   * The directory where the mock files are located.
   * @default 'mock'
   * mock/api: mock files
   * mock/scenes: scene files
   * mock/schemas: schema file
   *   scene.schema.json: scene schema file
   *   config.schema.json: config schema file
   * mock/utils: utility files
   * mock/config.json: configuration file
   */
  mockDir: string

  /**
   * mock client ui
   */
  client?: {
    /**
     * enable client
     * @default true
     */
    enable?: boolean
    /**
     * The port to run the client server.
     */
    port?: number
    /**
     * auto open browser.
     */
    open?: boolean
  }
}

Todo

  • filename as url when url not set
  • click settings icon show config in dialog
  • 添加 UI 创建场景合集功能