• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    TypeScript
  • License
    Other
  • Created over 3 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

⚑ Development Server with Live Reload Capability. (Maintained Fork of Live Server)

Five Server

Development Server with Live Reload Capability.
(Maintained Fork of Live Server)

  • Rewritten in TypeScript
  • Up-to-date dependencies
  • Better than ever!

Visual Studio Marketplace Rating Sponsors NPM version Github Workflow Github Workflow Downloads Node version Codecov


Top Features

  • πŸš€ Remote Logs
    Displays the logs of your browser in your terminal!
    Useful for debugging on your smart phone for example.

  • πŸš€ PHP Server
    Serves not only your .html files but also .php.
    See docs below

  • πŸš€ Server Side Rendered App
    Works with any Server Side Rendered content like Express.js!
    See docs below

  • πŸš€ Instant Updates
    Updates your html page while typing!
    (VSCode Extension only)

  • πŸš€ Highlights
    Highlights the code you are working on in your browser!
    (VSCode Extension only)

  • πŸš€ Auto Navigation
    Navigates your browser automatically to the current editing .html file!
    (VSCode Extension only)

Get Started

# Remove live-server (if you have it)
$ npm -g rm live-server

# Install five-server
$ npm -g i five-server

# Run it
$ five-server

# Update five-server (from time to time)
$ npm -g i five-server@latest

Usage

Five Server is written in TypeScript. Since it is nearly impossible to have a clean import for all module resolvers without restricting/adding explicit access to submodules via the exports property in package.json (which I don't want), I just list some very simple import examples.

Once everyone uses Modules in Node.js, I'm happy to make adjustments.

// TypeScript
import FiveServer from 'five-server'
new FiveServer().start({ open: false })

// Node.js Module
import FiveServer from 'five-server/esm.mjs'
new FiveServer().start({ open: false })

// Node.js Module (alternative)
import pkg from 'five-server'
const { default: FiveServer } = pkg
new FiveServer().start({ open: false })

// CommonJS
const FiveServer = require('five-server').default
new FiveServer().start({ open: false })

Documentation

Will be available soon.

Config File

Reference:

You will find all available options for your Config File in /src/types.ts.

A simple example of a config file:

Your browser will open the about page of your portfolio project at http://localhost:8085/about.html.

// .fiveserverrc
{
  "port": 8085,
  "root": "src/portfolio",
  "open": "about.html"
}

Another example:

Firefox (if available) will open https://127.0.0.1:8086/about.html and https://127.0.0.1:8086/contact.html.

// fiveserver.config.js
module.exports = {
  port: 8086,
  root: 'src/portfolio',
  open: ['about.html', 'contact.html'],
  host: '0.0.0.0',
  browser: 'firefox',
  https: true
}

(The https certificate is self-signed. Means, the first time you open your browser, you have to confirm that you want to continue.)

Debug on your Mobile Device

Allows you to connect your mobile device by making your server accessible externally.
You will see all logs from the mobile device in your terminal in yellow.

// fiveserver.config.js
module.exports = {
  host: '0.0.0.0', // default: '0.0.0.0' (could also be 'localhost' for example)
  remoteLogs: 'magenta' // true | false | Color
  useLocalIp: true, // optional: opens browser with your local IP
}

Watch & Ignore:

Watch only for file changes in /src. But exclude all .sass and .scss files from watching.

// fiveserver.config.js
module.exports = {
  // ...
  watch: 'src',
  ignore: /\.s[ac]ss$/i

  // can also be an array:
  // watch: ['src', 'public'],
  // ignore: [/\.s[ac]ss$/i, /\.tsx?$/i]
}

To prevent a single page from automatically reloading, add data-server-no-reload to the <body> tag:

<!doctype html>
<html lang="en">
<head>
    ...
</head>
<body data-server-no-reload>
  ...
</body>
</html>

This will omit the usually injected Javascript from being instantiated on that given page.

Browser of your choice

The option browser can be a string or an string[].
If you provide an array, the first browser found will be opened.

Following options are all valid:

'chrome'
['firefox', 'chrome --incognito']
['C:\\Program Files\\Firefox Developer Edition\\firefox.exe --private-window']

# if 'chrome' does not work, try 'google chrome' or 'google-chrome'

PHP Server

Serve and auto-reload PHP file in your browser!

Simply add the path to your PHP executable.

module.exports = {
  php: '/usr/bin/php', // Linux/macOS (example)
  php: 'C:\\xampp\\php\\php.exe' // Windows (example)
}

Cache

By default, the caching route (/.cache) is activated.

If in development you often load files from a CDN (styles, images, scripts, etc.), you might not want to make a http request to the CDN server on every reload. To prevent this and load your assets faster, simply add the cache attribute or manually prepend /.cache/ to your resources.

Example:

<!-- adding "cache" ... -->
<link cache rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" />

<!-- will convert this ... -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" />

<!-- into this. -->
<link rel="stylesheet" href="/.cache/https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" />

Server Side Rendering (like express.js)

You can enable live reload for any server side generated content.

Check out the express.js example at /examples/express.

Simply start Five Server and add the script below to you files:

<script async data-id="five-server" src="http://localhost:8080/fiveserver.js"></script>

Add this config file:

// fiveserver.config.js
module.exports = {
  https: false,
  host: 'localhost',
  port: 8080,
  open: false // or open your express.js app (http://localhost:3000/ for example)
}

VSCode Extension

Download it from marketplace.visualstudio.com.

Logo

fiveserver logo

License

See LICENSE

More Repositories

1

phaser-project-template

πŸ•ΉοΈ Phaser 3 - Starter Template with TypeScript and webpack.
TypeScript
408
star
2

phaser3-multiplayer-with-physics

Phaser 3 - Real-Time Multiplayer example with Physics (MatterJS and Arcade)
TypeScript
177
star
3

phaser-project-template-es6

Phaser 3 - Starter Template with ES6 (ESNext features included) and webpack.
JavaScript
149
star
4

five-server-vscode

⚑ VSCode Extension for Five Server.
TypeScript
121
star
5

phaser3-typescript-platformer-example

Phaser 3 TypeScript Platformer Example
JavaScript
81
star
6

phaser3-matter-car-on-curved-terrain

Phaser 3 + Matter.js: Car on curved terrain crosses a bridge
TypeScript
48
star
7

arcade-physics

Use Arcade Physics without Phaser.
JavaScript
47
star
8

phaser3-react-typescript-example

Phaser 3: with React and TypeScript Example
TypeScript
39
star
9

docker-swarm-visualizer

πŸ‹ A Visualizer for Docker Swarm using the Docker Engine API and Node.js.
TypeScript
35
star
10

phaser3-spine-example

JavaScript
35
star
11

docker-swarm-visualizer-rs

πŸ‹ A Visualizer for Docker Swarm written in Rust.
TypeScript
19
star
12

phaser3-optimal-resolution

JavaScript
18
star
13

phaser3-scaling-resizing-example

Phaser 3 - Scaling/Resizing Example
TypeScript
17
star
14

html2app-template

HTML
17
star
15

express6

πŸ… Modern, fast, unopinionated, minimalist web framework.
TypeScript
16
star
16

five-server-with-php

PHP
14
star
17

node-cli

πŸ–οΈ Build a beautiful Node.js CLI with colors, pre-build elements and optional JSX support.
TypeScript
13
star
18

gitget

πŸ“¦ Clone GitHub repos fast and easy.
TypeScript
11
star
19

ammo-worker-test

JavaScript
10
star
20

three-project-template

Three.js starter template with TypeScript and webpack.
TypeScript
10
star
21

phaser-basic-template

Phaser 3: Basic Starter Template with Intellisense
JavaScript
10
star
22

keyboard

⌨️ Handling of keyboard events.
TypeScript
9
star
23

phaser3-swipeable-level-selection

A very nice swipeable level selection menu for Phaser 3 games.
TypeScript
9
star
24

postgres-browser-proxy

🐘 Query your Postgres Database directly from the Browser.
Rust
8
star
25

react-to-static-or-ssr

A react starter template for creating single page applications, static html files or a server side rendered app.
TypeScript
5
star
26

kronos2-prototype

TypeScript
4
star
27

ionic-react-typescript-starter

Ionic 5 & React - Starter Template written in TypeScript
TypeScript
4
star
28

tauri-webxr-test

Rust
4
star
29

tap

πŸ–±οΈ Handling of user interactions such as mouse, touch and pointer events.
TypeScript
4
star
30

yandeu

3
star
31

events

⚑ Simplified and TypeScripted version of [email protected]
JavaScript
3
star
32

audio

🎡 Audio library for the Web Audio API. (TypeScripted version of Three.js@r126's Audio without Object3D)
TypeScript
3
star
33

handlebars-to-static-or-ssr

Run Handlebars on the Server Side (with node.js and express) or generate Static HTML files.
JavaScript
2
star
34

parse-markdown

TypeScript
2
star
35

docker-php

πŸ‹ A simple PHP environment with Docker for local development.
JavaScript
2
star
36

phaser-phonegap-template

HTML
2
star
37

tiny-http2-server

TypeScript
2
star
38

markdown-mail

πŸ“¬ Turn your Markdown files into Responsive HTML E-Mails.
TypeScript
1
star
39

struct-serval

Rust
1
star
40

www

HTML
1
star
41

wordpress-docker-compose

A simple docker-compose file to spin up WordPress, MariaDB and phpmyadmin.
1
star
42

arcade-physics_dev

JavaScript
1
star
43

video-to-m3u8

HTML
1
star
44

ftp-upload

Rust
1
star
45

nano-jsx-simple-template

JavaScript
1
star
46

npm-template

A simple template for making npm packages.
JavaScript
1
star
47

rust-rocket-mongodb

Rust
1
star
48

nordpress_preview

Dev Repository for nordpress.org
1
star
49

old-phaser-template

JavaScript
1
star
50

tarif590-json

Tarif590 to JSON - Turns "Tarif_590.xlsx" into "tarif590.json".
JavaScript
1
star
51

md-to-book

JavaScript
1
star