boilerplate for creating a react component library/npm package with typescript
Built with yarn 1.22.17 and node v14.17.3
|
|- lib/ //build output
|- src/ //library code
|- test/ //create-react-app where components can be viewed/tested
|
yarn install
Installs dependencies in both library and create-react-apptest/
directoryyarn build
Builds library intolib
directoryyarn start
Starts the create-react-app test applicationyarn publish
Runs a build then publishes library to npm (Will need tonpm login
first)
In src/
there is a simple Demo Component. Any component you wish to test will need to be imported in the package.json
of the create-react-app (test
) directory.
It is advised to use the local link:..
syntax (as done with the Demo Component) instead of publishing and pulling the library down from npm each time.
You will need to build the library (yarn build
) in order for the create-react-app to pickup changes to components.