npm 打包组件库

为了方便代码公用,打造简易组件库,下面写的教大家打包到发布,基于react

初始化项目

mkdir component-lib

进入并且初始化git

cd component-lib && git init
git remote add origin [git@github.com](mailto:git@github.com):alanbsmith/component-lib.git

npm 配置 (我也不知道有啥用)
$ npm set init.author.email "you@example.com"
$ npm set init.author.url "http://yourblog.com"
$ npm adduser
npm 初始化
$ npm init
name: (component-lib)
version: (1.0.0) 0.1.0
description: an example component library built with React!
entry point: (index.js) build/index.js
test command:
git repository:
keywords:
license: (ISC)About to write to /Users/alanbsmith/personal-projects/trash/package.json:
{
"name": "component-lib",
"version": "0.1.0",
"description": "an example component library built with React!",
"main": "build/index.js",
"scripts": {"test": "echo \"Error: no test specified\" && exit 1"},
"author": "Alan Smith <[alan.smith@example.com](mailto:a.bax.smith@gmail.com)> ([https://github.com/alanbsmith](https://github.com/alanbsmith))","license": "ISC"}
Is this ok? (yes)
下面就是项目创建
$ mkdir lib
$ touch .babelrc .eslintrc .gitignore .npmignore CODE_OF_CONDUCT.md README.md
$ touch lib/index.js
$ mkdir lib/components lib/elements lib/styles
$ npm install babel-cli babel-core babel-eslint babel-preset-es2015 babel-preset-react eslint eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-watch polished prop-types react react-dom styled-components --save-dev

. babelrc

{
  "presets": ["es2015", "react"]
}

写不下了 接第2 篇

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • .eslintrc .gitignore .npmignore README.md 这个可以自己yy CODE_...
    big5阅读 766评论 1 1
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,581评论 2 45
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,009评论 19 139
  • 2016年11月3日凌晨,来自山东青岛的女留学生江歌在东京都野火车站接回同住的女友刘鑫时,在公寓楼门口遇到刘鑫的前...
    木锦萱阅读 445评论 11 3
  • 念 不念 是相思 亦是怀恋 曾一眼瞬间 却如永隔万年 人海茫茫待重见 苦苦寻觅只因所念 然世间事终难遂人愿 这次第...
    易Jane阅读 181评论 1 0