• Stars
    star
    191
  • Rank 202,877 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vercel builder for Sapper with SSR enabled

vercel-sapper (a.k.a. now-sapper)

Vercel builder for Sapper with SSR enabled

What's in it for you?

  • Deploy your Sapper app as a Lambda in 30 seconds.
  • Serve all static assets from a CDN.

Automatic configuration

Run npx vercel-sapper on an existing project.

Or create a new project with npx vercel-sapper my-project

πŸ§ͺ This feature is experimental, let us know what you think => #47

Manual configuration

You must make 3 changes to your project to get started:

  1. Configure vercel-sapper as builder in vercel.json
  2. Export the server instance in src/server.js
  3. Ignore the local build folder __sapper__

To install a working example of a vercel-sapper template ready for deployment or development, see the examples directory.

cd examples/sapper-template
node install.js
1. Configure vercel-sapper as builder in vercel.json
{
  "version": 2,
  "builds": [{ "src": "package.json", "use": "vercel-sapper" }]
}
2. Export the server instance in src/server.js
const app = express() // or polka()
// app.use(...)
// app.listen(...)
export default app
3. Ignore the local build folder __sapper__

Example .vercelignore :

__sapper__
node_modules

Consider also ignoring the cypress folder if you are not running tests.

4. Deploy to Vercel

Run vercel to build and deploy your project. You can install the vercel cli by running npm i -g vercel

Run sapper dev for local development. vercel dev does not work for local development

Options

Node.js version

You can change the Node.js version with the engines field.

Example package.json

{
  "engines": {
    "node": "12.x"
  }
}
Include files outside the __sapper__ folder

The static folder is always hosted on the Vercel CDN. Before v0.42 it was also included in the lambda function. Here is how to include it again:

Example vercel.json

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "vercel-sapper",
      "config": {
        "include": ["static"]
      }
    }
  ]
}
Memory Configuration

You can change the amount of memory your lambda runs with. This is useful to optimise costs.

Note that reducing memory also reduces the amount of CPU available to the lambda, so try some values before you optimise too much.

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "vercel-sapper",
      "config": {
        "memory": 3008
      }
    }
  ]
}

Where builds[].config.memory can be any value allowed by AWS Lambda.

No-build usage

Useful if you are building the project on CI, and then want to just push the compiled source.

Recommended .vercelignore:

__sapper__/dev
__sapper__/export
cypress
node_modules

Example vercel.json

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "vercel-sapper",
      "config": {
        "build": false
      }
    }
  ]
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions and feedback are very welcome.

This project aims to enable developers to deploy to Vercel with minimal config. New features should be in line with other builders like now-next. Please see the now Developer Reference for more info.

More Repositories

1

rollup-plugin-serve

Serve your rolled up bundle like webpack-dev-server
JavaScript
248
star
2

rollup-plugin-livereload

LiveReload your Rollup bundle!
TypeScript
158
star
3

rollup-plugin-scss

Rollup and compile multiple .scss, .sass and .css imports
TypeScript
134
star
4

rollup-plugin-css-only

Rollup plugin that bundles imported css
JavaScript
116
star
5

payload-plugin-oauth

Add oAuth sign in to your Payload CMS site
TypeScript
79
star
6

rollup-plugin-vue2

Rollup plugin for Vue 2.0 components with precompiled templates
JavaScript
61
star
7

pilon

Pilon, easy wifi hotspot for Raspberry Pi, pay with bitcoin
PHP
41
star
8

Airtable-to-Figma

Figma plugin to import Airtable data into Figma components
HTML
25
star
9

kirby-plugins

Plugins for Kirby CMS
PHP
20
star
10

vuejs-templates-rollup

Vue + Rollup + Buble + Livereload + dev-server + CSS extraction
JavaScript
19
star
11

svelte-number-gauge

JavaScript
9
star
12

payload-components

Some custom Payload components
TypeScript
8
star
13

payload-plugin-resolve-alias

Shorthand to add common webpack aliases
TypeScript
7
star
14

hivepanel

TypeScript
7
star
15

impostor.party

Web-based game inspired by Among Us
TypeScript
3
star
16

rollup-plugin-url-import

Resolve URL imports just like Deno
JavaScript
3
star
17

deno-rollup

Rollup CLI for deno
JavaScript
2
star
18

gitroom

Collaborate on a git branch by syncing your working directory
JavaScript
1
star
19

util

Stuff I often need.
JavaScript
1
star
20

gnss

Debug GNSS devices using WebSerial
TypeScript
1
star
21

wdcommunity-website

HTML
1
star
22

schemaorg-redesign

A responsive redesign & offline-first PWA of schema.org https://schemaorg-redesign.now.sh
HTML
1
star
23

heart-coherence-app

TypeScript
1
star
24

ethicsandsport.com

Static assets for ethicsandsport.com
HTML
1
star
25

hidden-territories

TypeScript
1
star
26

messenger-extension-tester

Debug & test Messenger Extensions locally
JavaScript
1
star
27

vue-year-calendar

Year calendar component for Vue 2
Vue
1
star
28

thehive.party

TypeScript
1
star
29

mindustry-webserver

Web interface for hosting a Mindustry server
TypeScript
1
star