Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Example gulpfile for complete set-up.
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var less = require('gulp-less');
var refresh = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
var minifyCSS = require('gulp-minify-css');
var embedlr = require('gulp-embedlr');
gulp.task('scripts', function() {
gulp.src(['app/src/**/*.js'])
.pipe(browserify())
.pipe(concat('dest.js'))
.pipe(gulp.dest('dist/build'))
.pipe(refresh(server))
})
gulp.task('styles', function() {
gulp.src(['app/css/style.less'])
.pipe(less())
.pipe(minifyCSS())
.pipe(gulp.dest('dist/build'))
.pipe(refresh(server))
})
gulp.task('lr-server', function() {
server.listen(35729, function(err) {
if(err) return console.log(err);
});
})
gulp.task('html', function() {
gulp.src("app/*.html")
.pipe(embedlr())
.pipe(gulp.dest('dist/'))
.pipe(refresh(server));
})
gulp.task('default', function() {
gulp.run('lr-server', 'scripts', 'styles', 'html');
gulp.watch('app/src/**', function(event) {
gulp.run('scripts');
})
gulp.watch('app/css/**', function(event) {
gulp.run('styles');
})
gulp.watch('app/**/*.html', function(event) {
gulp.run('html');
})
})
@bd3717eb

This comment has been minimized.

Show comment Hide comment
@bd3717eb

bd3717eb May 25, 2016

hi! Can U speak spanish ? need help

hi! Can U speak spanish ? need help

@RedTurk

This comment has been minimized.

Show comment Hide comment
@RedTurk

RedTurk Aug 9, 2017

Great! gulpfile, soft, clean and tutorial.

RedTurk commented Aug 9, 2017

Great! gulpfile, soft, clean and tutorial.

@Maelfyn

This comment has been minimized.

Show comment Hide comment
@Maelfyn

Maelfyn Dec 1, 2017

gulp.run() is deprecated. Now what?

Maelfyn commented Dec 1, 2017

gulp.run() is deprecated. Now what?

@lucasomigli

This comment has been minimized.

Show comment Hide comment
@lucasomigli

lucasomigli Dec 4, 2017

Great! Thanks for the clean code!
Anyways, may I ask if someone could comment the code out so to be more specific about what is actually happening? It would be nice especially for people using gulp for the first times... like me! :)

Great! Thanks for the clean code!
Anyways, may I ask if someone could comment the code out so to be more specific about what is actually happening? It would be nice especially for people using gulp for the first times... like me! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment