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

local-mock-easy

v1.1.0

Published

A easy debug plugin for eruda and vConsole.

Downloads

2

Readme

English | 简体中文

local-mock-easy

A easy debug plugin for eruda and vConsole.

local-mock full solution, reference local-mock-core

Note: local-mock-easy is only the client (H5) part of local-mock-core, complete local-mock debugging solution needs to install local-mock-middleware on the server (nodejs) at the same time, follow steps:

  1. Install local-mock-middleware on the nodejs server.
  2. Install local-mock-easy on the client.

Features

  • 🎉without proxy, you do not need to map domain to local. (like: Charles Map Remote)
  • 🚀devServer only, you do not need to start the node server at the same time.
  • 🌻One-click debugging, through the local-mock-easy plugin, you can start debugging on the mobile machine with one click.
  • 🌻Both static and gateway scenarios are supported, nodejs gateway proxy forwarding static resources and public network domain map to local static resources are both supported.

Get Started

Install

npm or yarn
npm i local-mock-easy
yarn add local-mock-easy
Using local-mock-easy from CDN
<script src="https://cdn.jsdelivr.net/npm/local-mock-easy"></script>
<script>
  const { erudaLocalMock, vconsoleLocalMock } = window.localMockEasy
  // You can also customize plugins for other debug panels through setup, renderLocalMock
  const { setup, renderLocalMock } = window.localMockEasy
</script>

Add plugin

Plugin for eruda

// #!if ENV === "development"
import eruda from 'eruda'
import { erudaLocalMock } from 'local-mock-easy'

eruda.init()

const localMockplugin = erudaLocalMock(eruda, {})

eruda.add(localMockplugin)
// #!endif

Plugin for vConsole

// #!if ENV === "development"
import VConsole from 'vconsole'
import { vconsoleLocalMock } from 'local-mock-easy'

const vconsole = new VConsole()

const localMockplugin = vconsoleLocalMock(VConsole, {
  key: 'myLocalMock',
  state: 0,
  entry: 'http://localhost:8080',
  fast: 0,
  // default agent mode, pleace install local-mock-middleware on nodejs gateway
  mode: 'agent',
})

vconsole.addPlugin(localMockplugin)
// #!endif

Config devServer

Since the entry file of 'devServer' is loaded in the domain name, you need to configure cross-origin and configure publicPath to load local static resources.

{
  "devServer": {
    "publicPath": "http://localhost:8080",
    "port": 8080,
    "headers": {
      "Access-Control-Allow-Origin": "*"
    }
  }
}

Mobile machine debugging

  • The cellular network needs to be on the same LAN as the localhost.
  • publicPath and proxy change to http://{ip}:{port}, such as: http://192.168.1.10:8080

Options API

| params | desc | type | default | | :-- | :-- | :-- | :-- | | state | plugin open state | number | 0 | | entry | the local entry | string | http://localhost:8080 | | key | the query params name in url. http://example.com?{key}={entry} | string | localMock | | fast | whether to show fast button | number | 0 | | mode | both static and gateway scenarios are supported | static or agent | agent |

FQA

If you have any problems please contact us or open issues.

Why you need to change IP address?

Because the page resources of lcoalhost:8080 cannot be accessed on the mobile machine