sorvor

command module
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 12 Imported by: 0

README

sørvør

extremely fast, zero config server for modern web applications.

✨ Features

  • Flexible EntryPoints - use HTML, CSS or JS as entry point for your application.
  • SPA Routing - redirects path requests to HTML entry point for frontend routing.
  • Asset Pipeline - great asset processing with simple primitives.
  • Live Reloading - live reload browsers on code change.
  • Bundle Libraries - bundle libraries for distribution using JS/TS/JSX/TSX entry points.
💪 Powered By
  • esbuild - an extremely fast JavaScript bundler.
  • golang - an expressive, concise, clean, and efficient programming language.

⚡ Installation

Use go binaries to install sørvør:

curl -sf https://gobinaries.com/osdevisnot/sorvor | sh

Alternatively, if you have go installed, use go get to install sørvør:

go get github.com/osdevisnot/sorvor

🍽 Usage

You can use sørvør as a local development server or as a build tool for your applications and/or NPM libraries.

Live Reloading Server

To serve an application using a live reloading server, use HTML as entrypoint and --dev command line argument.

For example:

sorvor --dev public/index.html
Build Applications for Production

Alternatively, you can build your application with sørvør using HTML as entrypoint. For Example:

sorvor public/undex.html
Bundle NPM Library

You can also bundle your library for distribution on NPM using a JS entrypoint. For example:

sorvor src/index.js

Example Projects

Check out the example projects for fully integrated setup.

😎 Asset Pipeline

sørvør provides great asset pipeline with simple primitives.

Build JS or CSS with esbuild

To run entry points from public/index.html through esbuild, use esbuild function in the index file

Example:

<script type="module" src="{{ esbuild "index.js" }}"></script>

This will bundle index.js file and serve the build output on local development server.

Enable Livereload

To enable livereload functionality, use livereload function in the index file

Example:

{{ livereload }}

💢 Configuration

For most part, sørvør tries to use sensible defaults, but you can configure the behaviour using command line arguments below:

cli argument description default value
--entry=... source directory for sørvør public/index.html
--port=... port for sørvør 1234
--dev enable development mode false

sørvør forwards all the other command line arguments to esbuild.

Please refer documentation for simple esbuild options or advance options to further customize the bundling process.

For example, to use esbuild with modern esm format, use a command like this:

sorvor --format=esm --dev

sørvør configures below values for esbuild as defaults:

cli argument description default value
--bundle enables bundling output files true
--write enables writing built output to disk true
--port=... port to start esbuild in serve mode 1235 (if --dev mode is enabled)
--outdir=... target directory for esbuild output dist

🐣 Motivations/Inspirations

sørvør started with desire to simplify frontend tooling, with strong focus on speed of execution. It uses esbuild for bundling modern javascript and typescript syntax to a lower target. The idea here is to implement features that esbuild deems as out of scope, but are necessary for a decent development environment.

This project is inspired by servør from Luke Jackson, which provides similar zero dependency development experience but lacks integration with bundler/build tools. I choose golang to implement this project to solidify my learning of the language and to achieve a zero dependency model.

🔬 Roadmap

This project currently lacks some extended features available in servør, some of which will be implemented in the future.

I want to avoid implementing features that are already on the roadmap for esbuild. The idea is to use esbuild as is without duplicating efforts.

🥂 License

sørvør is licensed under the MIT License.

Documentation is licensed under Creative Commons License.

Created with ❤️ by @osdevisnot and all contributors.

Documentation

Overview

an extremely fast, zero config server for modern web applications.

Directories

Path Synopsis
pkg
livereload
Package livereload implements HTML5 Server Side Events to live reload connected browsers Usage: first start the livereload instance liveReload := livereload.New(root) liveReload.Start() then, install an HTTP handler on desired path http.Handle("/livereload", liveReload) The target browser must support HTML5 Server Side Events.
Package livereload implements HTML5 Server Side Events to live reload connected browsers Usage: first start the livereload instance liveReload := livereload.New(root) liveReload.Start() then, install an HTTP handler on desired path http.Handle("/livereload", liveReload) The target browser must support HTML5 Server Side Events.
logger
Package logger provides color coded log messages with error handling
Package logger provides color coded log messages with error handling

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL