Posted By

Pjotor on 09/24/15


Tagged

javascript npm Gulp


Versions (?)

Quick'n'Dirty gulp dev server


 / Published in: JavaScript
 

URL: pjotor.com

Create package.json & gulpfile.js, with the content in the snipplet.

Run: npm i -D

Run: gulp [-p #PORT#][-r #ROOTPATH#][-l #ENABLEDIR_LISTING#]

...and you're done

  1. //package.json
  2. {
  3. "dependencies": {
  4. "gulp": "*",
  5. "gulp-webserver": "*",
  6. "yargs": "*"
  7. }
  8. }
  9.  
  10.  
  11. //gulpfile.js
  12. var gulp = require('gulp'),
  13. webserver = require('gulp-webserver'),
  14. argv = require('yargs').argv;
  15.  
  16. gulp.task('webserver', function () {
  17. gulp.src(argv.r || '.')
  18. .pipe(webserver({
  19. port: argv.p || 8000,
  20. directoryListing: argv.l || false,
  21. livereload: true
  22. }));
  23. });
  24.  
  25. gulp.task('default', ['webserver']);

Report this snippet  

You need to login to post a comment.