AllenYuan

build - default - fin

Apr 22nd, 2020
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // html task: move index.html (entry point for the browser) to ./build/
  2. gulp.task('html', function () {
  3.   return gulp
  4.     .src('src/index.html')
  5.     .on('error', interceptErrors)
  6.     .pipe(gulp.dest('./build/'));
  7. });
  8.  
  9. // default task (this run when you do 'gulp' in the command line)
  10. // run html and browserify to put all the html+JS into ./build/, then serve the assets
  11. // in ./build/ to the browser at localhost:4000.
  12. gulp.task('default', ['html', 'browserify'], function () {
  13.   // serve assets to localhost:4000
  14.   browserSync.init(['./build/**/**.**'], {
  15.     server: './build',
  16.     port: 4000,
  17.     notify: false,
  18.     ui: {
  19.       port: 4001,
  20.     },
  21.   });
  22.  
  23.   // watch for changes and recompile changed files with html, view, browserify tasks respectively.
  24.   gulp.watch('src/index.html', ['html']);
  25.   gulp.watch(viewFiles, ['views']);
  26.   gulp.watch(jsFiles, ['browserify']);
  27. });
Advertisement
Add Comment
Please, Sign In to add comment