https://github.com/metonym/template-lib-svelte
Template for building Svelte component libraries
https://github.com/metonym/template-lib-svelte
component-library rollup svelte template webpack
Last synced: about 2 months ago
JSON representation
Template for building Svelte component libraries
- Host: GitHub
- URL: https://github.com/metonym/template-lib-svelte
- Owner: metonym
- License: mit
- Created: 2020-01-19T19:23:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-01T15:07:46.000Z (about 6 years ago)
- Last Synced: 2025-09-17T23:55:53.817Z (10 months ago)
- Topics: component-library, rollup, svelte, template, webpack
- Language: JavaScript
- Size: 312 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# template-lib-svelte
[](https://travis-ci.com/metonym/template-lib-svelte)
[](https://codecov.io/gh/metonym/template-lib-svelte)
> Template for building Svelte component libraries.
## Workflow
- **Development**: develop the library using a webpack set-up ([`app/`](app/))
- **Testing**: unit test the library using [Jest](https://github.com/facebook/jest) and [@testing-library/svelte](https://github.com/testing-library/svelte-testing-library)
- **Building**: build the library using [Rollup](https://github.com/rollup/rollup) to support ES/UMD formats
- **Publishing**: publish the library to [NPM](https://www.npmjs.com/)
- **Documentation**: deploy the compiled webpack set-up to [GitHub Pages](https://pages.github.com/)
## Getting Started
Clone the repository:
```bash
git clone git@github.com:metonym/template-lib-svelte.git
cd template-lib-svelte
```
Install its dependencies:
```bash
yarn install
```
## Development
When developing, use the webpack app set-up in the `app/` folder to reload any changes to the library.
```bash
cd app
yarn install
yarn start
```
## Available Scripts
### `yarn build`
Builds the library for production using [Rollup](https://github.com/rollup/rollup) and outputs artifacts to the `lib` folder.
#### Build Formats
```js
// package.json
{
"svelte": "src/index.js", // preferred Svelte entry
"main": "lib/index.js", // UMD build
"module": "lib/index.mjs" // ES Module build
}
```
### `yarn test`
Runs tests using [Jest](https://github.com/facebook/jest) with [@testing-library/svelte](https://github.com/testing-library/svelte-testing-library) and generates a coverage report.
### `yarn test:tdd`
Runs tests in watch mode.
## Publishing to `npm`
### 1) Update the Library Name
Update the library name in [package.json](package.json) and [rollup.config.js](rollup.config.js).
```diff
{
- "name": "template-lib-svelte",
+ "name": ""
}
```
```diff
// rollup.config.js
if (UMD) {
- output.name = 'template-lib-svelte';
+ output.name = '';
}
```
## License
[MIT](LICENSE)