17-publish-component-library 中文文档教程
Publish Component Library
Base Depenencies
yarn add --dev \
rollup \
rollup-plugin-babel \
rollup-plugin-node-resolve \
rollup-plugin-commonjs \
@babel/core \
@babel/preset-env \
@babel/preset-react
yarn add --peer \
react \
styled-components
Bundle
yarn bundle
通过 Rollup
- -c, --config
Use this config file (if argument is used but value is unspecified, defaults to rollup.config.js) - -f, --format
: Type of output (amd, cjs, esm, iife, umd) - use esm for frontend component library
插件:
- rollup-plugin-node-resolve: Use the Node.js resolution algorithm with Rollup (formerly rollup-plugin-npm)
- rollup-plugin-commonjs: Convert CommonJS modules to ES2015
- [rollup-plugin-babel]():
Publish
yarn publish
Usage
yarn add react styled-components 17-publish-component-library
import { Spinner } from "17-publish-component-library";
<Spinner />;
Publish Component Library
Base Depenencies
yarn add --dev \
rollup \
rollup-plugin-babel \
rollup-plugin-node-resolve \
rollup-plugin-commonjs \
@babel/core \
@babel/preset-env \
@babel/preset-react
yarn add --peer \
react \
styled-components
Bundle
yarn bundle
By Rollup
- -c, --config
Use this config file (if argument is used but value is unspecified, defaults to rollup.config.js) - -f, --format
: Type of output (amd, cjs, esm, iife, umd) - use esm for frontend component library
Plugins:
- rollup-plugin-node-resolve: Use the Node.js resolution algorithm with Rollup (formerly rollup-plugin-npm)
- rollup-plugin-commonjs: Convert CommonJS modules to ES2015
- [rollup-plugin-babel]():
Publish
yarn publish
Usage
yarn add react styled-components 17-publish-component-library
import { Spinner } from "17-publish-component-library";
<Spinner />;