0.2.0 ā€¢ Published 1 year ago

vercel-dev-server v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Vercel dev server

Based on discussions on Vercel repository, there is no way to use vercel dev command inside a monorepo.

This package aims to emulate the dev server of vercel in order to make it usable with multiple vercel project inside the same repository.

Setup

You know the song, install the dependency with your favourite package manager.

pnpm add -D vercel-dev-server
yarn add -D vercel-dev-server
npm install -D vercel-dev-server
// dev.js

const { createVercelServer } = require("vercel-dev-server");

createVercelServer().then((server) => {
  const PORT = 8080;
  const HOST = "127.0.0.1";

  // `server` is a basic http server.
  // It can takes all params mentionned in Node.js documentation
  // https://nodejs.org/api/http.html#serverlisten
  // https://nodejs.org/api/net.html#serverlistenoptions-callback
  server.listen({
    host: HOST,
    port: PORT,
  });

  console.log(`šŸƒā€ā™‚ļø Server started on http://${HOST}:${PORT}`);
});

After that you can create a script in your package.json in order to launch it with a short command line

pnpm add -D nodemon
{
  "scripts": {
    "dev": "nodemon dev.js"
  }
}

The last is the creation of a Vercel project. You must have an api folder with your cloud functions inside.

/
ā”œā”€ node_modules/
ā”œā”€ api/
ā”‚  ā”œā”€ [id].js
ā”‚  ā”œā”€ index.js
ā”‚  ā”œā”€ info.js
ā”œā”€ dev.js
ā”œā”€ package.json

This package doesn't transpile your code. Check examples folder to see how to use it with custom config.

0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago