Skip to content

Instantly share code, notes, and snippets.

@vedovelli
Last active January 8, 2016 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedovelli/08d28c4aa34a0eba5ebb to your computer and use it in GitHub Desktop.
Save vedovelli/08d28c4aa34a0eba5ebb to your computer and use it in GitHub Desktop.
Gulp + Duo + Browsersync + Uglify
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var uglify = require('gulp-uglify');
var exec = require('child_process').exec;
var srcDir = './src/**/*.js';
var jsIn = './src/main.js';
var jsOut = './build/main.js';
gulp.task('default', ['browser-sync', 'duo', 'watch']);
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "screencast-duo.app",
notify: false
});
});
/**
* Pega o arquivo gerado pelo Duo e minifica
*/
gulp.task('compress', function()
{
return gulp.src(jsOut)
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
/**
* Compila main.js (ver var jsIn acima) usando Duo.
*/
gulp.task('duo', function()
{
exec('duo --stdout ' + jsIn + ' > ' + jsOut, function (err, stdout, stderr)
{
console.log(err);
console.log(stdout);
console.log(stderr);
});
});
/**
*
*/
gulp.task('watch', function() {
gulp.watch(["**/*.html"]).on('change', browserSync.reload);
/**
* Sempre que o arquivo compilado pelo Duo for salvo, minifica e atualiza o browser
*/
gulp.watch([jsOut], ['compress']).on('change', browserSync.reload);
/**
* Observa qualquer arquivo na pasta /src
*/
gulp.watch([srcDir], ['duo']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment