Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vutran/hot-reload-server

A simple webpack hot reload server using webpack-dev-middleware and webpack-hot-middleware
https://github.com/vutran/hot-reload-server

hot-reloading javascript node webpack

Last synced: 6 days ago
JSON representation

A simple webpack hot reload server using webpack-dev-middleware and webpack-hot-middleware

Awesome Lists containing this project

README

        

# webpack hot-reload-server

Simple hot reload server.

[![NPM](https://nodei.co/npm/hot-reload-server.png?compact=true)](https://nodei.co/npm/hot-reload-server/)

# Usage

**server.js**

````js
import path from 'path';
import webpackConfig from './webpack.config';
import hotReloadServer from '../index';

// create the server
let server = hotReloadServer(webpackConfig);

// expose the public directory
server.expose(path.join(__dirname, 'public'));

// start the server
server.start();
````

**webpack.config.js**

````js
// Load modules
import path from 'path';
import webpack from 'webpack';

// Create an empty config
export default {
entry: [
'webpack-hot-middleware/client',
path.join(__dirname, 'entry.js')
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
hotReloadServer: {
address: 'localhost',
port: 4000
},
devtool: '#source-map',
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
};
````

**entry.js**

````js
document.write('It works!');

// check if HMR is enabled
if (module.hot) {
// accept itself
module.hot.accept();
}
````

**index.html**

````js

````

# Changelog

## 0.1.0
- Rewritten as ES6 module
- Updated example

## 0.0.4
- Exposed express and expres app instance