Skip to content

Instantly share code, notes, and snippets.

@realph
Last active August 29, 2015 14:21
Show Gist options
  • Save realph/93c6a470e13b488e27ba to your computer and use it in GitHub Desktop.
Save realph/93c6a470e13b488e27ba to your computer and use it in GitHub Desktop.
Gulp Zero Tasks
gulp.task('js', function () {
// define our sole entry point (source file)
return browserify({entries: ['./src/js/app.js']})
// bundle our js
.bundle()
// create a vinyl object
.pipe(source('app.js'))
// convert vinyl file to buffer
.pipe(buffer())
// create our source maps
.pipe(sourcemaps.init({loadMaps: true}))
// minify js
.pipe(uglify())
.on('error', gutil.log)
// write our sourcemaps
.pipe(sourcemaps.write('./'))
// save js to destination folder
.pipe(gulp.dest('./Build/js'))
// reload browser
.pipe(reload({stream: true}));
});
gulp.task('sass', function(event) {
// define our scss source directories
return gulp.src(['./src/scss/*.scss', './src/scss/**/*.scss'])
// pass our files through plumber, preventing any pipe breaking caused by errors
.pipe(plumber())
// complies sass to css
.pipe(sass())
// uses autoprefixer to add vendor prefixes to our css
.pipe(prefix({
browsers: ['last 2 versions'],
cascade: false
}))
// minifies css
.pipe(minifyCSS())
// saves css file to destination
.pipe(gulp.dest('./Build/css'))
// informs browser of change and reloads browser
.pipe(reload({stream: true}))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment