Skip to content

Instantly share code, notes, and snippets.

Created January 27, 2016 14:35
Show Gist options
  • Save jenyayel/f644bea988c0b1be2aaa to your computer and use it in GitHub Desktop.
Save jenyayel/f644bea988c0b1be2aaa to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var runSequence = require('run-sequence');
var changed = require('gulp-changed');
var plumber = require('gulp-plumber');
var to5 = require('gulp-babel');
var sourcemaps = require('gulp-sourcemaps');
var paths = require('../paths');
var compilerOptions = require('../babel-options');
var assign = Object.assign || require('object.assign');
var notify = require("gulp-notify");
var rename = require('gulp-rename');
// transpiles changed es6 files to SystemJS format
// the plumber() call prevents 'pipe breaking' caused
// by errors from other gulp plugins
gulp.task('build-system', function () {
return gulp.src(paths.source)
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(changed(paths.output, {extension: '.js'}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(to5(assign({}, compilerOptions, {modules:'system'})))
.pipe(sourcemaps.write({includeContent: true}))
// builds environment configurations
gulp.task('build-environment', function () {
return gulp.src('environments/' + (process.env.APP_ENV || 'production') + '.js')
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(changed(paths.output, {extension: '.js'}))
.pipe(to5(assign({}, compilerOptions)))
// copies changed html files to the output directory
gulp.task('build-html', function () {
return gulp.src(paths.html)
.pipe(changed(paths.output, {extension: '.html'}))
// copies changed css files to the output directory
gulp.task('build-css', function () {
return gulp.src(paths.css)
.pipe(changed(paths.output, {extension: '.css'}))
// this task calls the clean task (located
// in ./clean.js), then runs the build-system
// and build-html tasks in parallel
gulp.task('build', function(callback) {
return runSequence(
['build-system', 'build-environment', 'build-html', 'build-css'],
Copy link

can any one shed some light on why is it really necessary to use gulp-changed plugin? isn't enough?

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