Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

brunch/hmr-brunch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HMR runtime for Brunch

Allows to use Hot Module Replacement in your Brunch projects.

Constraints:

  • Only works for JS files
  • Requires brunch v<unreleased> and later
  • Requires auto-reload-brunch v<unreleased> and later
  • Provides the main HMR API (but not Management API)
  • Works only if your JS compiles to a single file

Usage

Change your config:

module.exports = {
  hot: true,
  // ...
};

Then, just use the main HMR API:

import React from 'react';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import counterApp from './reducers';
import App from 'components/App';

const store = createStore(counterApp, 0);
// detect if we're loading for the first time or reloading
if (module.hot) {
  module.hot.accept('./reducers', (d) => {
    store.replaceReducer(require('./reducers').default);
  });
}

Note: in production environment, hmr-brunch will strip all if (module.hot) { ... } conditionals.

About

Hot Module Replacement runtime for Brunch

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •