1.0.2 • Published 8 years ago

webpack-browser-sync-css-hmr v1.0.2

Weekly downloads
4
License
MIT
Repository
-
Last release
8 years ago

webpack-browser-sync-css-hmr

Naive implementation of HMR for CSS when using Webpack & Browsersync.

Sample usage:

const browsersync = require('browser-sync').create();
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const AnsiToHTML = require('ansi-to-html');
const convert = new AnsiToHTML();

const webpackConfig = require('./webpack.config')('development');
const bundler = webpack(webpackConfig);

bundler.plugin('done', function(stats) {
  if (stats.hasErrors() || stats.hasWarnings()) {
    // This is optional but chances are you'll want it.
    return browsersync.sockets.emit('fullscreen:message', {
      title: 'Error:',
      body: convert.toHtml(stats.toString({ colors: true })),
      timeout: 100000
    });
  } else {
    return browsersync.sockets.emit('styles:update');
  }
});

browsersync.init({
  host: 'localhost',
  port: 3000,
  proxy: 'https://wordpress.local/',
  open: false,
  files: ['**/*.css, **/*.js, **/*.php'],
  logFileChanges: false,
  plugins: ['bs-pretty-message', 'webpack-browser-sync-css-hmr'],
});
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago