Live Reload

Learning Gulp : part 16 of 22 published on Aug 17, 2015

Lets link our css file in index.html.

<!-- /contents/index.html -->
<!DOCTYPE html>
  <title>Learning Gulp</title>
  <link rel="stylesheet" href="/styles/main.min.css" />
  <h1>Hello Gulp!</h1>

Now let’s turn on live reload with our gulp-webserver.

// /gulpeFile.js
gulp.task('webserver', function() {
  return gulp.src('build')
    .pipe(webserver({ livereload: true }));

If we run gulp webserver in one terminal and gulp watch in another, we will have our webserver running and live refreshing on each build.

terminal 1

$ gulp webserver

terminal 2

$ gulp watch

Go to http://localhost:8000 to watch our webpage.

Update the css file to:

/* /contents/styles/some_styles.css */
h1 {
  color: blue;

And watch as the header goes from red to blue.

Next: Markdown