Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/bodjay/svelte-library-template

This is a project template for Svelte libraries.
https://github.com/bodjay/svelte-library-template

hacktoberfest

Last synced: 3 months ago
JSON representation

This is a project template for Svelte libraries.

Lists

README

        

# svelte library template

This is a project template for [Svelte](https://svelte.dev) libraries. It lives at https://github.com/henriquecaraujo/svelte-library-template.

To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):

```bash
npx degit henriquecaraujo/svelte-library-template svelte-library
cd svelte-library
```

_Note that you will need to have [Node.js](https://nodejs.org) installed._

## Get started

Install the dependencies...

```bash
cd svelte-library
npm install
```

...then start [Rollup](https://rollupjs.org):

```bash
npm run dev
```

Navigate to [localhost:5000](http://localhost:5000). You should see your library running on a example application. Edit a component file in `src`, save it, and reload the page to see your changes.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.

## Building and running in production mode

To create an optimised version of the library:

```bash
npm run build
```

You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).

## Single-page app mode

By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.

## Deploying to the web

### On [NPMjs](https://www.npmjs.com/)

After finish your awesome library, yarn the follow command

```bash
npm run build
```

Then, from the `dist` folder, generated by build command, execute the follow command:

```bash
npm publish
```

Note: to use this library in sapper, install as devDependency. See the [link](https://github.com/sveltejs/sapper-template#using-external-components).

Feel free to contribute!