Everything you need to build a Svelte library, powered by create-svelte
.
Read more about creating a library in the docs.
If you're seeing this, you've probably already done this step. Congrats!
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
- Everything inside
src/lib
is part of library, - Everything inside
src/routes
can be used as a showcase or preview app.
# start the server to test current changes
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
To build your library:
npm run package
To create a production version of your showcase app:
npm run build
This will copy the contents to dist
folder which is referred from package.json
so that any other package can use this as their dependency.
You can preview the production build with npm run preview
.
Since Github pages config supports only root folder or "/docs" folder, we are building the static site to docs folder.
npm run build
This will build static site to "docs" folder, as configured in svelte.config.js
. This can be launched in browser.
To publish it on npm, run npm run package
. It'll generate all require files in dist
folder. files
property in package.json
has the list of files to be published. So if you're referring any image in README.md, remember to include it in files
.