All Projects → alloc → viteflare

alloc / viteflare

Licence: MIT license
Cloudflare workers meet Vite plugins

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to viteflare

vite-plugin-cloudflare
🔥Building Cloudflare workers is faster and easier using vite-plugin-cloudflare with node builtins like process and stream
Stars: ✭ 108 (+208.57%)
Mutual labels:  workers, cloudflare, vite
cloudflare-worker-rest-api
A cloudflare worker module which helps building REST Api quickly and easily, similar to express framework.
Stars: ✭ 31 (-11.43%)
Mutual labels:  workers, cloudflare
natural
Fastest Framework for NodeJS. Written in pure ES6+
Stars: ✭ 30 (-14.29%)
Mutual labels:  workers, cloudflare
cloudflare-worker-graphql-ws-template
A template for WebSockets powered Cloudflare Worker project using graphql-ws
Stars: ✭ 21 (-40%)
Mutual labels:  workers, cloudflare
workers-jwt
Generate JWTs on Cloudflare Workers using the WebCrypto API
Stars: ✭ 67 (+91.43%)
Mutual labels:  workers, cloudflare
Create Google Shared Drive
Cloudflare Redesigned Script for creating a Shared/Team Drive
Stars: ✭ 93 (+165.71%)
Mutual labels:  workers, cloudflare
worker-template-postgres
Reference demo and modified PostgreSQL driver to connect Cloudflare Workers to a relational database.
Stars: ✭ 75 (+114.29%)
Mutual labels:  workers, cloudflare
Cfworker
A collection of packages optimized for Cloudflare Workers and service workers.
Stars: ✭ 152 (+334.29%)
Mutual labels:  workers, cloudflare
Worker Typescript Template
ʕ •́؈•̀) TypeScript template for Cloudflare Workers
Stars: ✭ 129 (+268.57%)
Mutual labels:  workers, cloudflare
Serverless Cloudflare Workers
Serverless provider plugin for Cloudflare Workers
Stars: ✭ 114 (+225.71%)
Mutual labels:  workers, cloudflare
Google Drive Index
Index Google Drive Files Easily and Free
Stars: ✭ 205 (+485.71%)
Mutual labels:  workers, cloudflare
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+311.43%)
Mutual labels:  workers, cloudflare
react-device-frameset
React device frameset component
Stars: ✭ 30 (-14.29%)
Mutual labels:  vite
duxravel
Duxravel 是基于 Laravel 框架和Arco Design Vue 开发的后台管理开发框架
Stars: ✭ 61 (+74.29%)
Mutual labels:  vite
vue-components-lib-seed
🌱 a vue3.0 components library template. Vue3.0 组件库的次佳实践.
Stars: ✭ 153 (+337.14%)
Mutual labels:  vite
cloudflared
Cloudflare Tunnel Instructions and Template for Unraid
Stars: ✭ 129 (+268.57%)
Mutual labels:  cloudflare
kubeflare
A Kubernetes Operator to manage Cloudflare settings via a declarative Kubernetes API
Stars: ✭ 50 (+42.86%)
Mutual labels:  cloudflare
react-vite-twin-macro
Just want to try react, vite and twin.macro
Stars: ✭ 17 (-51.43%)
Mutual labels:  vite
rgutil
rgutil是基于ES6创建的函数库工具
Stars: ✭ 22 (-37.14%)
Mutual labels:  vite
howdyjs
一个包含Javascript插件、Vue3组件、Vue3指令的工具库
Stars: ✭ 77 (+120%)
Mutual labels:  vite

viteflare

npm Code style: Prettier Donate

ViteFlare is a thin wrapper around Cloudflare Wrangler v2 (which is in beta), and it brings the flexibility of Vite-powered plugins (and Vite's vibrant plugin ecosystem) to Cloudflare workers.

 

What does this do?
Along with freeing your Cloudflare workers from being either contained in one file or bundled with Webpack, it allows your workers to be transformed using Vite plugins before they're deployed. It also provides a remote dev environment that exactly reproduces how Cloudflare workers operate in production.

What does this not do?
It does not run Vite within your worker.

 

Quick Start

Clone this template: alloc/viteflare-template

Use degit for a blazing fast setup locally:

npx degit https://github.com/alloc/viteflare-template my-worker

Manual Setup

pnpm install viteflare vite -D

Each worker needs its own directory that contains a package.json and wrangler.toml file. Optionally, it can also contain a vite.config.js file. The main field in its package.json should point to a module that exports a Cloudflare worker.

// Example worker module
import { defineWorker } from 'viteflare'

export default defineWorker({
  fetch(request, bindings, context) {
    return Promise.resolve(new Response('hello world'))
  },
})

Note: defineWorker is only required when using TypeScript.

 

Develop your worker

# In your worker's directory:
pnpm viteflare

# or pass a relative path:
pnpm viteflare path/to/worker/directory

Note: You might use yarn viteflare instead, if you prefer.

This runs your worker remotely. By default, your worker listens to port 8787, but you can use --port 1234 to change that. Currently, running multiple workers at once is not supported.

Debugging

Press d in the terminal while viteflare is running. This opens up Chrome devtools for your worker. The devtools will refresh whenever your worker is re-bundled.

 

Publish your worker

# In your worker's directory:
pnpm viteflare publish

# or pass a relative path:
pnpm viteflare publish path/to/worker/directory

 

Command forwarding

Every command supported by the wrangler CLI also works with the viteflare CLI, because ViteFlare will simply forward unimplemented commands to Wrangler v2.

pnpm viteflare login

This means you'll never have to install wrangler@beta when using ViteFlare.

 

Configuration

ViteFlare adds convenient features to Wrangler where it sees fit, including the wrangler.toml configuration file. This section describes such features.

vars.default

Normally, the top-level vars section is not inherited by environments. But values within the [vars.default] section will be inherited (ViteFlare only).

[vars]
FOO = 123 # Not inherited by [env.production.vars]

[vars.default]
FOO = 456 # Inherited by all environments (unless overridden)

[env.production.vars]
BAR = 123

 

Environment variables

The following variables are recognized by ViteFlare CLI.

# Override "account_id" in wrangler.toml
CF_ACCOUNT_ID=fcaf04c1e81c7db9b41b551ae7ccc949
# Skip the Cloudflare login flow
CF_API_TOKEN=secret

 

Examples

  • Type-checking demo link
    Check for compile-time type errors with TypeScript

    Screenshot

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].