@sartech/new-sample-package
v1.0.0
Published
Sample NPM Package
Readme
@sartech/new-sample-package
A sample React component library that provides a reusable ChatWidget UI. Built with Vite and published as a CommonJS bundle with bundled styles.
Installation
npm install @sartech/new-sample-packageThis package requires React 18+ as peer dependencies:
npm install react react-domUsage
Import the component and its styles in your React app:
import ChatWidget from '@sartech/new-sample-package';
import '@sartech/new-sample-package/style.css';
function App() {
return (
<div>
<ChatWidget />
</div>
);
}You can also use the named export:
import { ChatWidget } from '@sartech/new-sample-package';
import '@sartech/new-sample-package/style.css';Exports
| Export | Type | Description |
| ------------ | --------- | ------------------------------------ |
| ChatWidget | Component | Default and named export — chat UI |
| style.css | Styles | Bundled SCSS styles for the widget |
Development
Clone the repo and install dependencies:
npm installBuild the library to the dist/ folder:
npm run buildScripts
| Script | Description |
| ------------------- | ---------------------------------------- |
| npm run build | Clean and build the library with Vite |
| npm run clean:dist| Remove the dist/ directory |
| npm run publish:package | Build and publish to npm (public) |
Publishing
The package is configured for public npm publishing under the @sartech scope. Before publishing:
- Run
npm run buildto generate freshdist/output. - Ensure you are logged in to npm:
npm login. - Publish with:
npm run publish:packageThe prepublishOnly script automatically runs the build before publish.
Project Structure
my-pacakge/
├── index.js # Library entry — re-exports ChatWidget
├── src/
│ └── chat/
│ ├── chat.jsx # ChatWidget React component
│ └── chat.scss # Component styles
├── dist/ # Built output (published to npm)
│ ├── index.cjs
│ ├── index.cjs.map
│ └── style.css
├── vite.config.mjs # Vite library build config
└── package.jsonRequirements
- Node.js — for development and building
- React >= 18.0.0
- React DOM >= 18.0.0
License
ISC
Author
sirisha
