Socket
Socket
Sign inDemoInstall

local-mock-h5

Package Overview
Dependencies
3
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

local-mock-h5

A h5 debug plugin for eruda and vConsole.


Version published
Maintainers
1

Readme

Source

English | 简体中文

local-mock-h5

A h5 debug plugin for eruda and vConsole.

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-h5 plugin, you can start debugging on the mobile machine with one click.

Get Started

Install

yarn add local-mock-h5

Add plugin

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

eruda.init()

const localMockplugin = erudaLocalMock(eruda, {
  state: '0',
  proxy: 'http://localhost:8080',
})

eruda.add(localMockplugin)
// #!endif
Plugin for vConsole
// #!if ENV === "development"
import VConsole from 'vconsole'
import { vconsoleLocalMock } from 'local-mock-h5'

const vconsole = new VConsole()

const localMockplugin = vconsoleLocalMock(VConsole, {
  state: '0',
  proxy: 'http://localhost:8080',
})

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
Why you need to change IP address?

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

Keywords

FAQs

Last updated on 06 Nov 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc