GithubHelp home page GithubHelp logo

vutran / hot-reload-server Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 17 KB

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

License: MIT License

JavaScript 97.68% HTML 2.32%
webpack hot-reloading javascript node

hot-reload-server's Introduction

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

hot-reload-server's People

Contributors

vutran avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fdionisi

hot-reload-server's Issues

Does this support Backbone?

Hello @vutran, thanks for starting this project. Have you tested it on any specific framework: React, Angular, Backbone? Most hot reloaders out there I see are for React, but my main app is in Backbone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.