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

vue-cli-plugin-sync-mock

v0.1.0

Published

Localized interface response data to achieve local debugging without remote server

Downloads

76

Readme

vue-cli-plugin-sync-mock

:truck: 实现离线调试后台接口:通过代理缓存接口响应数据到本地,并开启本地文件代理服务。

安装

首先你需要先全局安装 @vue/cli

然后在你的项目根目录执行以下命令:

vue add sync-mock

配置

在项目根目录下的文件 vue.config.js (如果没有请创建)中添加:

module.exports = {
  devServer: {
    proxy: {
      // ...在这里设置你的代理配置
    }
  },
  pluginOptions: {
    // 该插件对应的配置
    syncMock: {
      sync: true
    }
  }
}

配置项说明

| 配置名 | 类型 | 描述 | |---|---|---| | sync | Boolean | 为 true 时开启接口代理离线缓存,否则不会缓存接口响应数据。 | | mock | Boolean | 开启后如果本地已经缓存有该接口的响应值,则会直接取本地缓存并返回,否则会继续走原代理接口 | | cachePath | String | 离线缓存文件存放地址。默认值:"project-root/node_modules/.cache/vue-cli-plugin-sync-cache/"|

注意:

该插件是通过代理实现离线缓存的,所以如果你没有配置任何代理,则不会生效。

补充说明

在后台服务可用的情况下开启 sync ,调试过程中自动缓存数据。

在后台服务由于某种原因不可用的情况下,开启 mock ,则调试过程中请求过的接口会从缓存中获取,不影响正常调试,同时保证数据为后台相对真实数据(虽然不实时)。