sorvor

command module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 10 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.
  • Secure Server - Supports https with trusted self signed certificates.
💪 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 --serve command line argument.

For example:

sorvor public/index.html --serve
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
--host=... host for sørvør localhost
--port=... port for sørvør 1234
--serve enable development mode false
--secure use https in dev mode false

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

Note: --secure automatically creates a self signed certificate for provided host.

to disable chrome warnings, open chrome://flags/#allow-insecure-localhost and change the setting to "Enabled".

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

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
--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 chose 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 also 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

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
authority
Package authority helps creating a self signed key and certs for TLS server Note: Adopted from https://golang.org/src/crypto/tls/generate_cert.go
Package authority helps creating a self signed key and certs for TLS server Note: Adopted from https://golang.org/src/crypto/tls/generate_cert.go
livereload
Package livereload implements HTML5 Server Side Events to live reload connected browsers Usage: first start the livereload instance liveReload := livereload.New() liveReload.Start() then, install an HTTP handler on desired path http.Handle("/livereload", liveReload) then, reload the connected browsers liveReload.Reload() 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() liveReload.Start() then, install an HTTP handler on desired path http.Handle("/livereload", liveReload) then, reload the connected browsers liveReload.Reload() 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
sorvor
Package sorvor is an extremely fast, zero config Server for modern web applications.
Package sorvor is an extremely fast, zero config Server for modern web applications.

Jump to

Keyboard shortcuts

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