${packageName}
.js - Web component bundle*.svelte
files in this directory will be loaded as build
starting points.Start with renaming the package in package.json
.
Make sure to use a safe namespace that allows mixing with any other
custom element sources.
Then run npm install
.
npm run dev
starts a local web server with the html page from the
public
folder. Live reload is enabled.
In development mode the bundled web component JS is not compressed.
To embed dev results into another local application, use the URL
http://localhost:8080/build/${packageName}.js
.
npm run build
will create the bundled and compressed web component
JS lib (IIFE encapsulated).
Each published svelte component begins with a configuration tag,
e.g.:
<svelte:options tag="webc-stub-button" immutable={true} />
The attribute tag
defines the name of the custom element. In this
example it would be:
<webc-stub-button></webc-stub-button>
Don't use existing html tag names without a namespace prefix.
Recommendation: Use the package name as name prefix.
Copy the bundled JS and picnic.min.css
to a web served
production location. Make sure they are both stored inside the same
folder / location.
In your web application, load the JS bundle as shown in the
index.html
example. Deferred loading will result in layout shift.
Use the new custom elements in your web application.