Skip to content

Template to create your own Typescript React library with Rollup.

License

Notifications You must be signed in to change notification settings

thiswallz/rollup-react-starter-lib-ts

Repository files navigation

rollup-react-starter-lib-ts

npm version install size license

Template to create your own Typescript React library with Rollup.

  • Rollup v3 🎉
  • Compatible with new and old React versions, generates ESM/CJS files.

Build & Publish

You can use this template and change the name under package.json.

Build

npm run build

Build & Watch

npm run build:watch

Publish (public library)

Be sure you are either logged in under npm login or you have a token (check https://docs.npmjs.com/creating-and-viewing-access-tokens).

npm run publish --access=public

For local testing

cd your-lib-folder/

npm link 

cd your-app/

npm link name-of-your-lib

Want to also minify bundle output?

You can install rollup-plugin-terser (still works with rollup v3, but since it has no updates, we need to install it with legacy peer options)

npm i rollup-plugin-terser --save-dev --legacy-peer-deps

Configure

rollup.config.mjs

import { terser } from 'rollup-plugin-terser';

...

 plugins: [
      peerDepsExternal(),
      resolve(),
      commonjs(),
      typescript({ tsconfig: "./tsconfig.json" }),
      terser(), // we add it here
 ]

About

Template to create your own Typescript React library with Rollup.

Resources

License

Stars

Watchers

Forks

Packages

No packages published