replacer-cli

a tool for reaplace all network resources to local

Usage no npm install needed!

<script type="module">
  import replacerCli from 'https://cdn.skypack.dev/replacer-cli';
</script>

README

🐳 replacer-cli

NPM Download NPM Version NPM License PRs Welcome

🔨 网络资源本地化工具 - 当部署环境为内网时,网络资源访问不了的时候,帮助你将网络资源本地化,而无需手动替换!

目录

注意事项

环境需求

Node.js 8.x

使用教程

快速开始

npm i replacer-cli -g 

# 安装完毕后可以使用 rep 运行

帮助

#bash
rep -h

Usage: rep [options] [command]

Options:
  -v, --version          output the version number
  -h, --help             output usage information

Commands:
  replace [dist]         替换指定目录的网络资源为静态资源
  proxy [target] [port]  启动静态资源服务器,并代理到指定的地址 proxy http://www.baidu.com 80 指的是请求代理到 target 启动的服务使用 80 端口
  init                   快速初始化你的仓库为镜像仓库

⬆ Back to Top

参数选项

rep replace [dist] [public_path]

public_path 默认为 /, 如果你的项目部署的时候需要多一层路径,则提供第二个参数

运行此命令会将 distDir 目录下的所有网络资源替换成本地资源

例子

case 1: rep replace dist

case 2: rep replace dist /public_path

before

image

after

image

rep proxy [target] [port]

本地资源替换成功后可以使用此命令查看是否还有网络资源在,相当于本地测试!target 是目标代理地址, port 非必填

例子

rep proxy http://127.0.0.1:9999

⬆ Back to Top

rep init

快速添加前端镜像化所需文件到项目中

例子

rep init

image

⬆ Back to Top

rep config [port]

本地拉起服务,快速的生成 auth_build.sh 文件内容, port 为端口号。

例子

rep config 9999

⬆ Back to Top

TODO

  • 快速添加给项目 .gitignore
  • 快速添加 eslint

⬆ Back to Top