本人是一个web前端开发工程师,主要是vue框架,整理了一些Vue常用的技术,一方面是分享,一方面是做总结,今后也会一直更新,有好建议的同学欢迎评论区分享 ;-)
Vue专栏:点击此处
Vue组件库专栏:点击此处
Vue2 vs Vue3 专栏:点击此处
Typescript专栏:点击此处
Vue组件库专栏会按顺序执行一下流程,不断完善组件库开发流程
文章按照组件库开发流程进行编写,其他内容可查看Vue组件库专栏 ,本章节开始发布npm包。
编码自述文件…
该文件会显示在发布的npm包的首页,看本文章最后一节,会展示~
npm官网:点击此处
npm官网package.json配置:点击此处
用了以下配置,可以实现关联依赖包自动加载,不过如果项目原先就引入了其他版本的element-plus会是怎么样呢??? 这里还没遇到过,大大们可以评论区发言~~~
npm i xxx 安装了你的包后,会自动下载element-plus,不用手动下载...
{
"name": "penk-ui",
"version": "1.0.2",
"description": "对elementPlus进行二次封装的组件库",
"files": [
"dist"
],
"keywords": [
"vue",
"element-plus",
"ui组件库二次封装"
],
"author": "penk",
"email": "[email protected]",
"homepage": "https://gitee.com/penk666/penk-ui",
"repository": {
"type": "git",
"url": "https://gitee.com/penk666/penk-ui.git"
},
"license": "ISC",
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit"
},
"peerDependencies": {
"element-plus": "^2.2.26"
},
"peerDependenciesMeta":{
"element-plus":{
"optional": true
}
},
"dependencies": {
"element-plus": "^2.2.26",
"vue": "^3.2.45"
},
"devDependencies": {
"@types/node": "^18.11.12",
"@vitejs/plugin-vue": "^4.0.0",
"@vue/tsconfig": "^0.1.3",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"npm-run-all": "^4.1.5",
"typescript": "~4.7.4",
"vite": "^4.0.0",
"vue-tsc": "^1.0.12"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"main": "./dist/penk-ui.umd.js",
"module": "./dist/penk-ui.es.js",
"exports": {
".": {
"import": "./dist/penk-ui.es.js",
"require": "./dist/penk-ui.umd.js"
},
"./dist/style.css": "./dist/style.css"
}
}
npm i penk-ui
自动下载了element-plus相关依赖包~~
测试了一下,可以直接在main.js 引入并且使用...
部分用户一些操作失败可能是源的问题,这边可以用nrm工具,实现快速切换源。
安装:点击此处
npm login
// 控制台会提示输入相关信息
Log in on https://registry.npmjs.org/
Username: // 用户名
Password: // 密码
Email: (this IS public) // 邮箱
Enter one-time password: // 如果之前做过 双因素身份验证 (2FA),验证码
Logged in as xxx on https://registry.npmjs.org/.
npm publish
penk-ui 包:点击此处