🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

webpack-browser-sync-css-hmr

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-browser-sync-css-hmr

HMR for CSS files using Browsersync & Webpack.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

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'],
});

Keywords

browser-sync

FAQs

Package last updated on 20 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts