Skip to content

Instantly share code, notes, and snippets.

@evdama
evdama / firebase.json
Created July 2, 2019 16:42
serving static via firebase hosting
{
"functions": {
"predeploy": [
"node predeploy.js"
],
"source": "functions"
},
"firestore": {
"rules": "config/firestore.rules",
"indexes": "config/firestore.indexes.json"
@evdama
evdama / server.js
Created July 2, 2019 17:30
working version of server.js
// @ts-nocheck TODO: remove at some point
// TODO: what todo with those two imports? needed? if so why and how?
//import config from './config';
//import './css/index.css';
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';
@evdama
evdama / rollup.config.js
Created July 4, 2019 02:33
rollup.config.js for sapper, tailwind and firebase
// @ts-nocheck TODO: remove at some point
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import config from 'sapper/config/rollup.js';
import getPreprocessor from 'svelte-preprocess'
import path from 'path'
import pkg from './package.json';
import postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace';
@evdama
evdama / client.js
Created July 4, 2019 12:56
correct way of using prefetchRoutes?
// @ts-nocheck
import * as sapper from '@sapper/app';
sapper.start( {
target: document.querySelector( '#sapper' )
} ).then( prefetchRoutes() );
@evdama
evdama / index.ts
Created July 7, 2019 03:52
firebase cloud function for sapper doing SSR with cache control
// @ts-nocheck TODO: remove once there are typings in place
// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript
const functions = require('firebase-functions');
// We have to import the built version of the server middleware.
const { app } = require('../__sapper__/build/server/server');
app.get('/', (request, response) => {
response.set(
@evdama
evdama / server.js
Created July 7, 2019 03:53
the server including helmet and sapper middleware
import './css/tailwind.css';
import * as sapper from '@sapper/server';
import compression from 'compression';
import express from 'express';
import helmet from "helmet";
import sirv from 'sirv';
const {
PORT,
NODE_ENV
@evdama
evdama / rollup.config.js
Created July 7, 2019 05:52
sapper project with tailwind using purgecss and cssnano
// @ts-nocheck TODO: remove at some point
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import config from 'sapper/config/rollup.js';
import getPreprocessor from 'svelte-preprocess'
import path from 'path'
import pkg from './package.json';
import postcss from 'rollup-plugin-postcss'
import replace from 'rollup-plugin-replace';
@evdama
evdama / index.ts
Created July 9, 2019 14:29
index.ts with cache control
// TODO: replace type any for request and response
// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript
const functions = require('firebase-functions');
// We have to import the built version of the server middleware.
const { app } = require('../__sapper__/build/server/server');
const oneHour = 60 * 60
const oneDay = oneHour * 24
// @ts-nocheck
// TODO: remove once there are typings in place
import './css/tailwind.css';
import * as sapper from '@sapper/server';
import compression from 'compression';
import express from 'express';
import helmet from "helmet";
import sirv from 'sirv';
import uuidv4 from 'uuid/v4';
@evdama
evdama / server.js
Created July 11, 2019 04:37
Sapper with content security enabled for script tags
// @ts-nocheck
// TODO: remove once there are typings in place
import './css/tailwind.css';
import * as sapper from '@sapper/server';
import compression from 'compression';
import express from 'express';
import helmet from "helmet";
import sirv from 'sirv';
import uuidv4 from 'uuid/v4';