Skip to content

Commit

Permalink
Release version 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
milankinen committed Oct 20, 2016
2 parents 9fe57be + 1ceea48 commit c5d6935
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 65 deletions.
59 changes: 0 additions & 59 deletions CHANGELOG.md

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ You can disable this de-duplication by using this flag.

Omits the reload client from the generated bundle.

#### `--ssl-cert <certFilename>` and `--ssl-key <privateKeyFilename>`

Adds your custom SSL certificate and key to the reload web-server. This is needed if you
want to use LiveReactLoad in HTTPS site. Parameters are paths to the actual files.


## License

MIT
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "livereactload",
"version": "3.0.1",
"version": "3.1.0",
"description": "Live code editing with Browserify and React",
"author": "Matti Lankinen <[email protected]> (https://github.com/milankinen)",
"license": "MIT",
Expand Down
7 changes: 4 additions & 3 deletions src/browserify-plugin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ function LiveReactloadPlugin(b, opts = {}) {
host = null,
client = true,
dedupe = true,
debug = false
debug = false,
'ssl-cert': sslCert = null,
'ssl-key': sslKey = null,
} = opts

// server is alive as long as watchify is running
const server = opts.server !== false ? startServer({port: Number(port)}) : null
const server = opts.server !== false ? startServer({port: Number(port), sslCert, sslKey}) : null

const clientOpts = {
// assuming that livereload package is in global mdule directory (node_modules)
Expand Down Expand Up @@ -154,4 +156,3 @@ function LiveReactloadPlugin(b, opts = {}) {
}

module.exports = LiveReactloadPlugin

21 changes: 19 additions & 2 deletions src/browserify-plugin/server.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import {Server} from "ws"
import {log} from "./console"
import https from 'https';
import {readFileSync} from 'fs';

function logError(error) {
if (error) {
log(error)
}
}

export function startServer({port}) {
const wss = new Server({port})
export function startServer({port, sslKey, sslCert}) {
if ((sslCert && !sslKey) || (!sslCert && sslKey)) {
throw new Error('You need both a certificate AND key in order to use SSL');
}

let wss;
if (sslCert && sslKey) {
const key = readFileSync(sslKey, 'utf8');
const cert = readFileSync(sslCert, 'utf8');
const credentials = {key, cert};
const server = https.createServer(credentials);
server.listen(port);
wss = new Server({server});
} else {
wss = new Server({port});
}


log("Reload server up and listening in port " + port + "...")

Expand Down

0 comments on commit c5d6935

Please sign in to comment.