Up package generator to create React Component package or React Hook Package
First, install Yeoman and generator-up using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-up
Then generate your new project:
yo up
The script will generate a Typescript boilerplate based on Vite.js and with a default example folder (for testing) and a src folder.
Of course, you will need to adapt it to your needs. Most important part will be inside the src folders and package.json folder.
Example with this package : https://github.com/uptoolkit/up-react.
When you create a package it might be cumbersome to access some very common data that you want to share (exemple the url of your api, the translations, a message error handler etc.)
That's why you can use the Up React hooks to handle that.
See : https://github.com/uptoolkit/up-react
When you will publish your package, you will need to define the dependencies that you don't want to be exported with your script. See the documentation here: https://vitejs.dev/guide/build.html#library-mode.
There is also a little script helper to publish directly your package into NPM.
cd YourPackageRootFolder
bash publish.sh
For more information : https://docs.npmjs.com/creating-and-publishing-scoped-public-packages
MIT © danielsum