美文网首页
npm 打包组件库

npm 打包组件库

作者: big5 | 来源:发表于2017-08-04 18:28 被阅读124次

为了方便代码公用,打造简易组件库,下面写的教大家打包到发布,基于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 篇

相关文章

  • npm 打包组件库

    为了方便代码公用,打造简易组件库,下面写的教大家打包到发布,基于react 初始化项目 mkdir compone...

  • @ant-design/icons-vue按需引入icon

    正常引入icon组件库 此时打包npm run build icons组件占用的资源很多,但是我们用到的icon不...

  • npm打包组件库2

    .eslintrc .gitignore .npmignore README.md 这个可以自己yy CODE_...

  • npm link

    npm 打包自己的组件库后,要修改组件库,怎么验证修改后的组件库被其他项目引用后达到了想要的效果? 这时可以使用n...

  • 在vue-cli中使用element-ui项目打包后图标不显示的

    在使用vue-cli搭建项目的时候,用了element-ui组件库的图标的,使用npm run build打包项目...

  • Vue项目webpack打包报错:Module not foun

    问题描述 今天在学习vue单文件组件的打包,在运行 npm run build 打包出现报错。 组件目录 comp...

  • 2018-06-17

    基于rollup的组件库打包体积优化 背景 前段时间对公司内部的组件库(类似element-ui)做了打包体积优化...

  • 9/19 课堂笔记

    mongodb(组件式开发) 安装mongodb组件 npm install mongodb 连接数据库思路 1 ...

  • 使用vue-pdf在Vue中进行pdf的预览下载

    1、使用npm 下载vue-pdf 2、封装pdf组件 3、在组件中具体使用封装的pdf组件 4、打包的时候会报错...

  • vue自定义组件库如何按需加载

    写好的组件库不要打包!不要打包!不要打包!直接引入源码在使用时把单个组件导入就行。打包了之后就没办法做到按需引入了

网友评论

      本文标题:npm 打包组件库

      本文链接:https://www.haomeiwen.com/subject/jlfblxtx.html