You can create your own component library to your applications with this template.
A base for building Svelte component library.
Original work is https://github.com/sveltejs/component-template
On GitHub:
Use this template
button on top right.
Read more: Creating a repository from a template
CLI:
npx degit patoi/svelte-component-library-template svelte-component-library-template
cd svelte-component-library-template
npm install # or yarn
Add your component's code to src/ as directory, e.g.: src/HelloComponent/ (or add your component directly to src/).
Export the new component to apps in src/index.js
src/test.js and src/App.svelte are for testing purposes:
npm install
npm run dev
:
public/
directory at http://localhost:5000
npm test
: test runnerFor changing the view of the test page use public/global.css and public/index.html
https://github.com/rollup/rollup-plugin-svelte#pkgsvelte
Tip: if you are a developer of the component library, then you can install it once as devDependencies to app with npm i -D <path-to-your-components>
, all change will appear immediately if you use livereload in app.
Import component library into your app in App.svelte
:
<script>
import { ByeBye, Hello } from 'svelte-component-library-template'
export let name
</script>
<Hello {name} />
<ByeBye {name} />
More: https://github.com/sveltejs/sapper-template/blob/master/README.md#using-external-components
svelte
https://svelte.devplaywright
for testing: https://playwright.deveslint
and prettier
for formatting and lintingrollupjs
for bundling: https://rollupjs.orgSupported Node.js v12 LTS and v14 LTS.