@eolink_apikit/mock-proxy-plugin

1.0.4 • Public • Published

简介

这是专属于 Eolink Mock 系统的前端 HTML 插件,支持 vite 以及 webpack 两款构建工具。

使用

安装

$ npm install @eolink_apikit/mock-proxy-plugin

引用

webpack

// 默认引入webpack
const EoMockProxyPlugin = require('@eolink_apikit/mock-proxy-plugin')
module.exports = {
  plugins: [
    new EoMockProxyPlugin({
      // config
    })
  ]
}

vite

const EoMockProxyPlugin = require('@eolink_apikit/mock-proxy-plugin/vite')
export default defineConfig({
  plugins: [vue(), new EoMockProxyPlugin(
    // config
  )]
})

配置

  • 实例化 EoMockProxyPlugin 时传参,如下示例:
    new EoMockProxyPlugin({
        "MOCK_API_HOST":"https://mockapi.eolink.com/",//[optional][string]
        "PROXY_MATCH_PATH:":"/api/v1/",//[optional][string]
        "IS_OPEN:":false //[optional][boolean]
    })
    
  • MOCK_API_HOST:[string] Eolink Mock API 统一的转发地址前缀,示例:https://mockapi.eolink.com/
  • PROXY_MATCH_PATH:[string] 拦截关键词,默认是/api/,假设所拦截的路径不包含此关键词,则默认请求原始路径,否则进入 mock 拦截器
  • IS_OPEN:[boolean] 是否开启 Mock 拦截器

注意

  • 因为此插件为 HTML 插件,所以假设项目构建工具为 weboack,则需要安装项目依赖插件:“html-webpack-plugin”

Readme

Keywords

Package Sidebar

Install

npm i @eolink_apikit/mock-proxy-plugin

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

17.4 kB

Total Files

11

Last publish

Collaborators

  • wisen
  • eolink