Web server

Learning Gulp : part 15 of 22 published on Aug 10, 2015

We can actually serve our webpages using a gulp plugin!

$ npm install gulp-webserver --save-dev
// gulpFile.js
...
var webserver = require('gulp-webserver');
...
gulp.task('webserver', function() {
  return gulp.src('build')
    .pipe(webserver());
});

Now when we run our gulp task webserver we will have a local webserver to view our website.

$ gulp webserver
Using gulpfile ~/js/gulpwalkthru/gulpFile.js
Starting 'webserver'...
Webserver started at http://localhost:8000
Finished 'webserver' after 20 ms

If you go to http://localhost:8000 in your web browser you should see our index.html page saying Hello Gulp!.

Next: Live Reload