hot-reload-server

    0.1.1 • Public • Published

    webpack hot-reload-server

    Simple hot reload server.

    NPM

    Usage

    server.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

    // 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

    document.write('It works!');
     
    // check if HMR is enabled
    if(module.hot) {
        // accept itself
        module.hot.accept();
    }

    index.html

    <script type="text/javascript" language="javascript" src="bundle.js"></script>

    Changelog

    0.1.0

    • Rewritten as ES6 module
    • Updated example

    0.0.4

    • Exposed express and expres app instance

    Install

    npm i hot-reload-server

    DownloadsWeekly Downloads

    24

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • avatar