npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-custom-component

v1.0.0-beta.15

Published

开发自定义组件脚手架

Downloads

70

Readme

开发自定义组件脚手架

开发流程

一、创建一个 vue2 的组件开发项目

# "my-component-app"新建的项目名称
npm create custom-component my-component-app

二、切换到项目根目录安装依赖

"my-component-app"新建的项目名称

cd my-component-app
npm install

三、生成组件

npm run new

通过交互式命令行,输入要生成的组件名称,会在 packages 目录下自动生成新的组件

三、本地开发调试

# 开发本地调试组件
npm run dev 

如果要本地调试打包组件,可以执行npm run build --watch, 配合 dev 启动的静态服务器,通过 http://localhost:5173/dist/index.umd.js 访问产物,修改组件代码时将会重新打包

四、打包

npm run build

build 命令会遍历packages下所有组件,选择要打包的组件即可

五、上传

将打包后的 index.umd.js 上传到cdn,将 cdn 地址更新到对应项目配置(前期通过项目写死,后期走 apollo 配置)

开发规范

  1. 所有组件的 style 必须加 scoped,以防污染全局样式
  2. 如果项目有引用其他库,例如 axios,可以与稿定侧开发沟通,如果主项目也有这个依赖,可以在 vite.config.js 里的 build.rollupOptions.external 里加上 axios,将 axios 移除打包
  3. 有需要引用主项目的某些组件,可以与稿定侧开发沟通,主项目将需要使用的组件通过 props 传入,自定义组件通过动态组件 <component :is="propComp"/> 加载
  4. props约定:使用方在开发自定义组件时,说明需要哪些属性、方法,稿定开发与其对接后,输出标准的对接文档
  5. 开发文档里不支持的组件,需要稿定提供支持的,使用方根据业务说明需要哪些属性、方法,稿定开发与其对接后,输出标准的对接文档(props、on),在开发文档里补充