- svelte boilerplate by lé for bundling an ollesvege component into a single IIFE .js file usable in an ollesvelke frontend (or any frontend project if placement is tweaked accordingly).
- ie. convert a
/component/lib
directory into acomponent.iife.js
file (+component.iife.js.map
) that can be used in a<script />
import. usage steps below: npm i
, paste contents of component/src/lib
folder into/src/lib
, addbundler.js
andvite.config.js
based onbundler-example.js
andvite-example.config.js
, update templateollesvege
variables inbundler.js
andvite.config.js
, andnpm run build
.- before building, you'll need to install modules used in your component as dev dependencies within ollescribe, ie.
npm i -D ...
. - builds
/dist > (your-component-name).iife.js, (your-component-name).iife.js.map
directory. - in the generated
.js
file, if your component has any parameters (ie.export let...
, eg.<script data-api-key="..." />
), replace any empty assignments in the.js
file with document.currentScript assignments, eg.let{api_key:p=""}
turns intolet{api_key:p=document.currentScript.getAttribute('data-api-key')}
. - copy the generated
.js
and.js.map
files over to your frontend's/static/js
directory. update the.js
file name as you like. - in your frontend's
src/routes/+layout.svelte
(or a specific page), add<script defer src="../../static/js/(your-component-filename)" …any parameters…></script>
in a<svelte:head>
injection. this is done in a.svelte
file rather than eg.index.html
so yourVITE_...
env variables can be accessed.
-
Notifications
You must be signed in to change notification settings - Fork 0
lefrost/ollescribe
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
⚡️ ollesvege to iife.js converter
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published