Skip to content

Instantly share code, notes, and snippets.

Loving SvelteJS

Antony Jones antony

Loving SvelteJS
View GitHub Profile
antony / build.js
Last active Mar 11, 2021
View build.js
const feather = require('feather-icons/dist/icons.json')
const pascal = require('just-pascal-case')
const { promises: fs } = require('fs')
const { join } = require('path')
const iconList = require('./icon-list.json')
const handleComponentName = name => name.replace(/\-(\d+)/, '$1')
const component = icon =>
antony /
Last active Feb 8, 2022
Auth0 SSR Compatible Integration with Sapper
npm install --save express express-openid-connect
antony / index.html
Last active Oct 24, 2020
Svelte App on Older Browsers (IE11+)
View index.html
<!-- generated via npm run build && npx create-polyfill-service-url analyse --file public/bundle.js -->
<script crossorigin="anonymous" src=",Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,,ArrayBuffer,console,DataView,Date.prototype.toISOString,document,fetch,Function.prototype.bind,globalThis,Map,Object.create,Object.defineProperties,Object.defineProperty,Object.entries,Object.getOwnPropertyDescriptor,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.getPrototypeOf,Object.keys,Object.setPrototypeOf,Promise,Reflect,Reflect.construct,Set,Symbol,Symbol.iterator,WeakMap,WeakSet"></script>
antony / index.js
Last active Jan 16, 2022
A very quick authentication server which validates a JWT
View index.js
'use strict'
require = require('esm')(module)
const { init, shutdown } = require('./server.js')
async function bootstrap () {
const server = await init()
await server.start()
console.log(`Server running at: ${}`)
View SimpleFileUploader.svelte
{#if uploading}
<Progress bind:percent={progress} text="Uploading..." />
{:else if processing}
<Progress percent={100} text="Processing..." />
<slot name="content">
antony / rollup.config.js
Last active Sep 15, 2019
Configuration variables in Svelte / Sapper
View rollup.config.js
import conf from 'config'
const appConfig = Object.keys(conf).reduce((acc, n) => {
acc[`process.env.${n}`] = JSON.stringify(conf[n])
return acc
}, {})
export default {
client: {
antony / SomeComponent.svelte
Last active Aug 15, 2019
Getting config from node-config into Sapper as `process.env.variableName`
View SomeComponent.svelte
antony / Flipper.svelte
Created Aug 10, 2019
An example of a div which can flip its content
View Flipper.svelte
<div class="card-container">
<div class="card">
{#if flipped}
<div class="side" transition:turn>
<slot name="front"></slot>
<div class="side back" transition:turn>
<slot name="back"></slot>
View Blob to Data Url
//**dataURL to blob**
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
u8arr[n] = bstr.charCodeAt(n);
return new Blob([u8arr], {type:mime});
antony / api.js
Created Dec 10, 2018
Universal Api Client for Sapper
View api.js
import querystring from 'querystring'
import fetch from 'node-fetch'
const base = `${process.env.apiUrl}/api/v1`
class HttpError extends Error {
class AccessDeniedError extends HttpError {