美文网首页
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 打包组件库

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