This is a project template for Svelte custom elements. It lives at https://github.com/Dan6erbond/svelte-custom-element-template.
To create a new project based on this template, clone this repository:
git clone https://github.com/Dan6erbond/svelte-custom-element-template.git
Note that you will need to have Node.js and Yarn installed on your machine.
cd svelte-custom-element-template
yarn
yarn dev
src
and Rollup's livereload
plugin will update the page in the browser.By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the srv
commands in the package.json
file to include the option --host 0.0.0.0
or add the option when running the development server.
index.html
.<script>
tags.build
: Builds the project for production.dev
: Runs the development server.start
: Starts the production server with built files.check
: Runs the Svelte & Typescript code checker.lint
: Runs ESLint with the Prettier plugin.format
: Runs Prettier.yarn build
dist
folder.<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<title>Svelte Custom Element</title>
<script src="bundle.js"></script>
</head>
<body>
<my-custom-element></my-custom-element>
</body>
</html>
This template is already setup with Typescript. Simply add lang="ts"
to your <script>
tag to use Typescript or use the .ts
extension for your Typescript files.
This project is licensed under the MIT License - see the LICENSE.md file for details.