Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/latentflip/building-static-server
A static file server that runs builds and things
https://github.com/latentflip/building-static-server
Last synced: 30 days ago
JSON representation
A static file server that runs builds and things
- Host: GitHub
- URL: https://github.com/latentflip/building-static-server
- Owner: latentflip
- Created: 2014-08-06T16:18:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-04T09:54:24.000Z (almost 10 years ago)
- Last Synced: 2024-04-15T02:17:42.109Z (7 months ago)
- Language: JavaScript
- Size: 278 KB
- Stars: 22
- Watchers: 2
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Building Static Server
* A static server that serves files in the current directory at a given port.
* That knows that you also have to build files, with maybe, Make.
* That will automatically just watch files for changes and rerun, Make/build step.
* That knows that when you refresh the browser, you'd rather wait for the current build to finish (if you change a file and quickly refresh) than be served old files.
* That knows that you like to use livereload.
* That doesn't care _how_ you build files\*, and doesn't take too much effort to setup.\* Though you should probably just use make ;)
## Usage
```bash
building-static-server -p 3001 -s 'make'
```* `-p` - port to start the server on
* `-s` - script to run, defaults to `npm run build` but you can use `make` or whateverI typically do it like this:
```js
//package.json
{
//...
"devDependencies": {
"building-static-server": "*"
},
"scripts": {
"build": "make build",
"start": "building-static-server -p 3001"
}
//...
}
```Then I can just do `npm start` and things will start. It will watch all your files for changes and rebuild on them. (So you should make sure make is configured nicely to prevent excessive rebuilds).
Add the [chrome livereload extension](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en) for extra fun.
## HTTPS
Use the `tls` option to enable HTTPS:
```bash
building-static-server -p 3001 -s 'make' --tls
```This uses a certificate authority, certificate and key file from the `certs` directory. Add `server.crt` to your keychain to avoid browser warnings.