How to use livereload - 10 common examples

To help you get started, we’ve selected a few livereload examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ulivz / w7 / src / dev-server.js View on Github external
/* eslint-disable unicorn/no-process-exit */
    process.exit(0)
  }

  const server = connect()

  server.use(livereload())
  server.use(serveStatic(cwd, {
    index: entry
  }))

  port = port || 4000

  server.listen(port)

  lrserver.createServer({
    exclusions: ['node_modules/']
  }).watch(cwd)

  if (openInBrowser) {
    open(`http://localhost:${port}`)
  }

  const msg =
    `\n  > Serving ${chalk.green(cwd)} now.
  > Entry File ${chalk.green(entry)}
  > Listening at ${chalk.green(`http://localhost:${port}`)}\n`
  console.log(msg)

  return server
}
github mediamonks / muban / build-tools / script / build.js View on Github external
function buildDev() {
  // cleanDist();

  // start preview server
  const serverConfig = previewServer();

  // reload the page on any file changes in the dist folder
  const livereload = require('livereload');
  const lrserver = livereload.createServer({
    // exts: ['html'],
  });
  lrserver.watch(config.buildPath);

  // build js/css in watch mode
  getWebpackConfig(webpackConfigCodeDev).then(configs => {
    webpack(configs).watch({
      ignored: ['**/*.hbs', 'node_modules']
    }, (err, stats) => {
      if (err) {
        return console.log(err);
      }
      displayWebpackStats(stats, true);

      console.log('webpack code done!');
      console.log();
github RossMcMillan92 / djent / dev.js View on Github external
// Build CSS
const cssSource     = './src/styles';
const cssBuild      = './dist';
const inputCSSPath  = `${cssSource}/app.sass`;
const outputCSSPath = `${cssBuild}/app.css`;
buildCSS(inputCSSPath, inputCSSPath, outputCSSPath, isBuild);

if (isBuild) return;

// Watch
watch(jsSource, (filename) => buildJS(filename, inputJSPath, outputJSPath))
watch(cssSource, (filename) => buildCSS(filename, inputCSSPath, outputCSSPath))

// Livereload
const server = livereload.createServer();
server
    .watch([outputJSPath, outputCSSPath])
    .on('change', (filename) => {
        console.log(`Reloaded: ${filename}`)
    });;
github rdev / expressx / src / lib / livereload.js View on Github external
import livereload from 'livereload';

const lr = livereload.createServer();

// Trigger livereload
export default function refresh() {
	lr.refresh('');
}
github mike-works / sass-fundamentals / src / server.js View on Github external
module.exports = function (opts) {
  var server = livereload.createServer({
    exts: ['scss', 'html']
  });
  let pth = path.join(__dirname, '..', 'exercises', opts.exercise, '**/*');
  server.watch(pth);

  let app = express();

  let sassMw = sassMiddleware({
    /* Options */
    src:  path.join(__dirname, '..', 'exercises', opts.exercise, 'src', 'sass'),
    dest: path.join(__dirname, '..', 'exercises', opts.exercise, 'public'),
    outputStyle: 'expanded'
  });

  // Note: you must place sass-middleware *before* `express.static` or else it will
  // not work.
github michaeloryl / angular2-bootstrap4-oauth2-webpack / server.js View on Github external
console.log("Request cookies: %j", req.cookies);
  console.log("Request originalUrl: %j", req.originalUrl);
  console.log("Request path: %j", req.path);
  console.log("Request query: %j", req.query);
  res.send('Received the callback');
});
app.use('/', express.static(__dirname + '/src'));
app.use('/public', express.static(__dirname + '/src'));
app.use('/protected', express.static(__dirname + '/src'));
app.use('/colin', express.static(__dirname + '/src'));
app.use('/auth/callback', express.static(__dirname + '/src'));

app.listen(3000);
console.log('Listening on port 3000.');

app = livereload.createServer({
  exts: ['html', 'css', 'js', 'png', 'gif', 'jpg', 'ts']
});

app.watch(__dirname + '/src');
console.log('Live reload enabled');
github Chimeejs / chimee / build / livereload.js View on Github external
const connect = require('connect');
const serveStatic = require('serve-static');
const path = require('path');

const server = connect();

server.use(serveStatic(path.resolve(__dirname, '../')));

server.listen(3000);

const livereload = require('livereload');
const lrserver = livereload.createServer();
lrserver.watch([ path.resolve(__dirname, '../demo'), path.resolve(__dirname, '../lib/index.dev.js') ]);

function closeServerOnTermination(server) {
  const terminationSignals = [ 'SIGINT', 'SIGTERM' ];
  terminationSignals.forEach(signal => {
    process.on(signal, () => {
      server.close();
      process.exit();
    });
  });
}

closeServerOnTermination(lrserver);
github flaviait / ng2-jspm-template / server / dev / livereload.js View on Github external
require("livereload")
  .createServer({
    port: require("../config.json").port.livereload
  })
  .watch([".tmp/main.css", "src/dev/index.dev.html"]);
github opencomponents / oc / src / cli / facade / dev.js View on Github external
getPort(port + 1, (error, otherPort) => {
                    if (error) {
                      return next(error);
                    }
                    const liveReloadServer = livereload.createServer({
                      port: otherPort
                    });
                    const refresher = () => liveReloadServer.refresh('/');
                    next(null, { refresher, port: otherPort });
                  });
                } else {
github formly-js / react-formly / gulpfile.js View on Github external
gulp.task('watch:serve', false, ['watch:serve:server'], function() {
  var server = livereload.createServer({
    interval: 300
  });
  server.watch(__dirname + '/demo');
});

livereload

LiveReload server

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular livereload functions