发布vue组件到verdaccio私有仓库

安装

npm install --location=global verdaccio@next

启动

npx verdaccio

配置文件位置

# 位置
~/.config/verdaccio/config.yaml
#主要修改以下内容

#包存储位置
storage: /abc/verdaccio/storage

#代理远程仓库地址
uplinks:
  npmjs:
    url: https://registry.npmmirror.com/

#修改上传包最大限制
max_body_size: 100mb

添加用户

npm adduser --registry http://localhost:4873/

发布

  1. 打包
vue-cli-service build --target lib --name my --dest my ./src/package/index.js
//index.js

import SeanElTable from './sean/SeanElTable.vue'
import { version } from '../../package.json'

const components = [SeanElTable]; // 将来如果有其它组件,都可以写到这个数组里

// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
const install = function (Vue) {
  // 判断是否安装
  if (install.installed) return
  install.installed = true
  // 遍历注册全局组件
  components.map(component => Vue.component(component.name, component))
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

// 按需引入
export {
  CkEditor,
  CkViewer,
  SeanElTable,
  MdEditor,
  MdViewer
}

export default {
  version,
  install
}
  1. 发布
#bin/bash

cp README.md my/

cp package.json my/package.json

npm publish my --registry http://localhost:4873/

echo "publish success"

删除已发布项目

npm unpublish my@1.0.0 --registry http://localhost:4873/

淘宝镜像

https://registry.npmmirror.com/

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值