<commit_before>'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var nodeunit = require('gulp-nodeunit');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');

gulp.task('all', ['clean', 'build', 'build-data']);

gulp.task('clean', function() {
  return gulp.src('build', {
    read: false
  })
  .pipe(rimraf());
});

gulp.task('build', function() {
  var files = [
    'src/tracking.js',
    'src/Brief.js',
    'src/Canvas.js',
    'src/EPnP.js',
    'src/ViolaJones.js',
    'src/Fast.js',
    'src/Image.js',
    'src/Math.js',
    'src/Matrix.js',
    'src/Tracker.js',
    'src/HAARTracker.js',
    'src/ColorTracker.js',
    'src/EyeTracker.js',
    'src/FaceTracker.js',
    'src/MouthTracker.js'
  ];

  return gulp.src(files)
    .pipe(concat('tracking.js'))
    .pipe(banner())
    .pipe(gulp.dest('build'))
    .pipe(uglify())
    .pipe(rename(function(filepath) {
      filepath.basename += '-min';
    }))
    .pipe(banner())
    .pipe(gulp.dest('build'));
});

gulp.task('build-data', function() {
  return gulp.src('src/data/**.js')
    .pipe(banner())
    .pipe(gulp.dest('build/data'))
    .pipe(rename(function(filepath) {
      filepath.basename += '-min';
    }))
    .pipe(uglify())
    .pipe(banner())
    .pipe(gulp.dest('build/data'));
});

gulp.task('lint', function() {
  return gulp.src('src/**.js')
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

gulp.task('test', function() {
  return gulp.src('test/*.js').pipe(nodeunit());
});

gulp.task('test-watch', function() {
  return gulp.watch(['src/*.js', 'test/**/*.js'], ['test']);
});

gulp.task('watch', function() {
  gulp.watch('src/*.js', ['build']);
  gulp.watch('src/data/*.js', ['build-data']);
});

// Private helpers
// ===============

function banner() {
  var stamp = [
    '/**',
    ' * <%= pkg.name %> - <%= pkg.description %>',
    ' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>',
    ' * @version v<%= pkg.version %>',
    ' * @link <%= pkg.homepage %>',
    ' * @license <%= pkg.license %>',
    ' */',
    ''
  ].join('\n');

  return header(stamp, { pkg: pkg });
}
<commit_msg>Adds DisjointSet dependency<commit_after>'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var nodeunit = require('gulp-nodeunit');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var rimraf = require('gulp-rimraf');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');

gulp.task('all', ['clean', 'build', 'build-data']);

gulp.task('clean', function() {
  return gulp.src('build', {
    read: false
  })
  .pipe(rimraf());
});

gulp.task('build', function() {
  var files = [
    'src/tracking.js',
    'src/Brief.js',
    'src/Canvas.js',
    'src/EPnP.js',
    'src/ViolaJones.js',
    'src/Fast.js',
    'src/Image.js',
    'src/Math.js',
    'src/Matrix.js',
    'src/DisjointSet.js',
    'src/Tracker.js',
    'src/HAARTracker.js',
    'src/ColorTracker.js',
    'src/EyeTracker.js',
    'src/FaceTracker.js',
    'src/MouthTracker.js'
  ];

  return gulp.src(files)
    .pipe(concat('tracking.js'))
    .pipe(banner())
    .pipe(gulp.dest('build'))
    .pipe(uglify())
    .pipe(rename(function(filepath) {
      filepath.basename += '-min';
    }))
    .pipe(banner())
    .pipe(gulp.dest('build'));
});

gulp.task('build-data', function() {
  return gulp.src('src/data/**.js')
    .pipe(banner())
    .pipe(gulp.dest('build/data'))
    .pipe(rename(function(filepath) {
      filepath.basename += '-min';
    }))
    .pipe(uglify())
    .pipe(banner())
    .pipe(gulp.dest('build/data'));
});

gulp.task('lint', function() {
  return gulp.src('src/**.js')
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

gulp.task('test', function() {
  return gulp.src('test/*.js').pipe(nodeunit());
});

gulp.task('test-watch', function() {
  return gulp.watch(['src/*.js', 'test/**/*.js'], ['test']);
});

gulp.task('watch', function() {
  gulp.watch('src/*.js', ['build']);
  gulp.watch('src/data/*.js', ['build-data']);
});

// Private helpers
// ===============

function banner() {
  var stamp = [
    '/**',
    ' * <%= pkg.name %> - <%= pkg.description %>',
    ' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>',
    ' * @version v<%= pkg.version %>',
    ' * @link <%= pkg.homepage %>',
    ' * @license <%= pkg.license %>',
    ' */',
    ''
  ].join('\n');

  return header(stamp, { pkg: pkg });
}
<|endoftext|>


<commit_before>const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const del = require('del');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');
const watchify = require('watchify');
const debowerify = require('debowerify');
const babelify = require('babelify');
const cssnext = require('postcss-cssnext');
const $ = require('gulp-load-plugins')();
const minimist = require('minimist');

const config = require('./config.json');

const knownOptions = {
  string: 'input',
  default: {input: 'example.json'},
  alias: {i: 'input'}
};

const argv = minimist(process.argv.slice(2), knownOptions);

const taskName = argv._[0];
const dataFile = argv.i;
const projectName = dataFile.slice(0, -5);

gulp.task(function mustache() {
  const DEST = '.tmp';

  try {
    const article = JSON.parse(fs.readFileSync('model/' + dataFile));
  } catch (e) {
    console.log(`Cannot read your data file: models/${dataFile}`);
    console.log(e);
    return;
  }

  const theme = article.lightTheme;

  const footer = JSON.parse(fs.readFileSync('model/footer.json'));

  const analytics = false;

  if (taskName === 'build' || taskName === 'deploy') {
    analytics = true;
  }

  return gulp.src('views/index.mustache')
    .pipe($.changed(DEST))
    .pipe($.mustache({
      theme: theme,
      analytics: analytics,
      article: article,
      footer: footer
    }, {
      extension: '.html'
    }))
    .pipe($.size({
      gzip: true,
      showFiles: true
    }))
    .pipe(gulp.dest(DEST))
    .pipe(browserSync.stream({once: true}));
});

gulp.task('styles', function styles() {
  const DEST = '.tmp/styles';

  return gulp.src('client/main.scss')
    .pipe($.changed(DEST))
    .pipe($.plumber())
    .pipe($.sourcemaps.init({loadMaps:true}))
    .pipe($.sass({
      outputStyle: 'expanded',
      precision: 10,
      includePaths: ['bower_components']
    }).on('error', $.sass.logError))
    .pipe($.postcss([
      cssnext({
        features: {
          colorRgba: false
        }
      })
    ]))
    .pipe($.size({
      gzip: true,
      showFiles: true
    }))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest(DEST))
    .pipe(browserSync.stream());
});

gulp.task('scripts', function() {
  const b = browserify({
    entries: 'client/main.js',
    debug: true,
    cache: {},
    packageCache: {},
    transform: [debowerify, babelify],
    plugin: [watchify]
  });

  b.on('update', bundle);
  b.on('log', $.util.log);

  bundle();

  function bundle(ids) {
    $.util.log('Compiling JS...');
    if (ids) {
      console.log('Chnaged Files:\n' + ids);
    }
    return b.bundle()
      .on('error', function(err) {
        $.util.log(err.message);
        browserSync.notify('Browerify Error!')
        this.emit('end')
      })
      .pipe(source('bundle.js'))
      .pipe(buffer())
      .pipe($.sourcemaps.init({loadMaps: true}))
      .pipe($.sourcemaps.write('./'))
      .pipe(gulp.dest('.tmp/scripts'))
      .pipe(browserSync.stream({once:true}));
  }
});

gulp.task('js', function() {
  const DEST = '.tmp/scripts/';

  const b = browserify({
    entries: 'client/main.js',
    debug: true,
    cache: {},
    packageCache: {},
    transform: [babelify, debowerify]
  });

  return b.bundle()
    .on('error', function(err) {
      $.util.log(err.message);
      this.emit('end')
    })
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe($.sourcemaps.init({loadMaps: true}))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest(DEST));
});

gulp.task('lint', function() {
  return gulp.src('client/**/*.js')
    .pipe($.eslint({
        extends: 'eslint:recommended',
        globals: {
          'd3': true,
          'ga': true,
          'fa': true
        },
        rules: {
          semi: [2, "always"]
        },
        envs: [
          'browser'
        ]
    }))
    .pipe($.eslint.format())
    .pipe($.eslint.failAfterError());
});

gulp.task('serve',
  gulp.parallel(
    'mustache', 'styles', 'scripts',

    function serve() {
    browserSync.init({
      server: {
        baseDir: ['.tmp', 'client'],
        routes: {
          '/bower_components': 'bower_components'
        }
      }
    });

    gulp.watch('client/**/*.{csv,svg,png,jpg}', browserSync.reload);
    gulp.watch('client/**/**/*.scss', gulp.parallel('styles'));
    gulp.watch(['views/**/*.mustache', 'model/*.json'], gulp.parallel('mustache'));
    //gulp.watch('client/**/*.js', gulp.parallel('lint'));
  })
);

gulp.task('serve:dist', function() {
  browserSync.init({
    server: {
      baseDir: ['dist'],
      routes: {
        '/bower_components': 'bower_components'
      }
    }
  });
});

/* build */
gulp.task('html', function() {
  return gulp.src('.tmp/index.html')
/*    .pipe($.useref({searchPath: ['.', '.tmp']}))
    .pipe($.if('*.js', $.uglify()))
    .pipe($.if('*.css', $.cssnano()))*/
    .pipe($.if('*.html', $.htmlReplace(config.static)))
    .pipe($.smoosher())
    .pipe(gulp.dest('dist'));
});

gulp.task('extras', function () {
  return gulp.src('client/**/*.csv', {
    dot: true
  })
  .pipe(gulp.dest('dist'));
});

gulp.task('images', function () {
  return gulp.src('client/images/*.{svg,png,jpg,jpeg,gif}')
    .pipe($.imagemin({
      progressive: true,
      interlaced: true,
      svgoPlugins: [{cleanupIDs: false}]
    }))
    .pipe(gulp.dest('dist/images'));
});

gulp.task('clean', function() {
  return del(['.tmp', 'dist']).then(()=>{
    console.log('.tmp and dist deleted');
  });
});

gulp.task('build', gulp.series('clean', gulp.parallel('mustache', 'styles', 'js', 'images', 'extras'), 'html'));

/**********deploy***********/
gulp.task('deploy:assets', function() {
  return gulp.src(['dist/**/*.{csv,png,jpg,svg}'])
    .pipe(gulp.dest(config.deploy.assets + projectName))
});

gulp.task('deploy:html', function() {
  return gulp.src('dist/index.html')
    .pipe($.prefix(config.prefixUrl + projectName))
    .pipe($.rename({basename: projectName, extname: '.html'}))
    .pipe($.htmlmin({
      removeComments: true,
      collapseWhitespace: true,
      removeAttributeQuotes: true,
      minifyJS: true,
      minifyCSS: true
    }))
    .pipe($.sizereport({
      gzip: true
    }))
    .pipe(gulp.dest(config.deploy.index));
});

gulp.task('deploy', gulp.series('build', gulp.parallel('deploy:assets', 'deploy:html')));

/* demos */
gulp.task("mustache:demos", function() {
  const DEST = '.tmp';

  const article = JSON.parse(fs.readFileSync('model/data.json'));

  const footer = JSON.parse(fs.readFileSync('model/footer.json'));

  return gulp.src('demos/*.mustache')
    .pipe($.changed(DEST))
    .pipe($.if('light-theme.mustache',
      $.mustache({
        theme: true,
        article: article,
        footer: footer
      }, {
        extension: '.html'
      }),
      $.mustache({
        theme: false,
        article: article,
        footer: footer
      }, {
        extension: '.html'
      })
    ))
    .pipe(gulp.dest(DEST))
    .pipe(browserSync.stream({once: true}));
});

gulp.task('copy:demos', function() {
  return gulp.src('demos/index.html')
    .pipe(gulp.dest('.tmp'))
    .pipe(browserSync.stream({once: true}));
});

gulp.task('images:demos', function() {
  return gulp.src('client/images/*.{svg,png,jpg,jpeg,gif}')
    .pipe($.imagemin({
      progressive: true,
      interlaced: true,
      svgoPlugins: [{cleanupIDs: false}]
    }))
    .pipe(gulp.dest('.tmp/images'));
});

gulp.task('build:demos', gulp.parallel('copy:demos', 'mustache:demos', 'styles', 'images:demos'));

gulp.task('watch:demos',
  gulp.parallel('copy:demos', 'mustache:demos', 'styles',
    function serve() {
    browserSync.init({
      server: {
        baseDir: ['demos', '.tmp', 'client'],
        routes: {
          '/bower_components': 'bower_components'
        }
      }
    });

    gulp.watch('client/**/*.{csv,svg,png,jpg}', browserSync.reload);
    gulp.watch('client/**/**/*.scss', gulp.parallel('styles'));
    gulp.watch('demos/*.html', gulp.parallel('copy:demos'));
    gulp.watch(['views/**/*.mustache', 'model/*.json', 'demos/*.mustache'], gulp.parallel('mustache:demos'));
    //gulp.watch('client/**/*.js', gulp.parallel('lint'));
  })
);

gulp.task('demos', gulp.series('clean', 'build:demos', function(){
  return gulp.src('.tmp/**/**')
    .pipe(gulp.dest(config.deploy.assets + projectName));
}));<commit_msg>watch:demos task use argv as data file name<commit_after>const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const del = require('del');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');
const watchify = require('watchify');
const debowerify = require('debowerify');
const babelify = require('babelify');
const cssnext = require('postcss-cssnext');
const $ = require('gulp-load-plugins')();
const minimist = require('minimist');

const config = require('./config.json');

const knownOptions = {
  string: 'input',
  default: {input: 'example.json'},
  alias: {i: 'input'}
};

const argv = minimist(process.argv.slice(2), knownOptions);

const taskName = argv._[0];
const dataFile = argv.i;
const projectName = dataFile.slice(0, -5);

gulp.task(function mustache() {
  const DEST = '.tmp';

  try {
    const article = JSON.parse(fs.readFileSync('model/' + dataFile));
  } catch (e) {
    console.log(`Cannot read your data file: models/${dataFile}`);
    console.log(e);
    return;
  }

  const theme = article.lightTheme;

  const footer = JSON.parse(fs.readFileSync('model/footer.json'));

  const analytics = false;

  if (taskName === 'build' || taskName === 'deploy') {
    analytics = true;
  }

  return gulp.src('views/index.mustache')
    .pipe($.changed(DEST))
    .pipe($.mustache({
      theme: theme,
      analytics: analytics,
      article: article,
      footer: footer
    }, {
      extension: '.html'
    }))
    .pipe($.size({
      gzip: true,
      showFiles: true
    }))
    .pipe(gulp.dest(DEST))
    .pipe(browserSync.stream({once: true}));
});

gulp.task('styles', function styles() {
  const DEST = '.tmp/styles';

  return gulp.src('client/main.scss')
    .pipe($.changed(DEST))
    .pipe($.plumber())
    .pipe($.sourcemaps.init({loadMaps:true}))
    .pipe($.sass({
      outputStyle: 'expanded',
      precision: 10,
      includePaths: ['bower_components']
    }).on('error', $.sass.logError))
    .pipe($.postcss([
      cssnext({
        features: {
          colorRgba: false
        }
      })
    ]))
    .pipe($.size({
      gzip: true,
      showFiles: true
    }))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest(DEST))
    .pipe(browserSync.stream());
});

gulp.task('scripts', function() {
  const b = browserify({
    entries: 'client/main.js',
    debug: true,
    cache: {},
    packageCache: {},
    transform: [debowerify, babelify],
    plugin: [watchify]
  });

  b.on('update', bundle);
  b.on('log', $.util.log);

  bundle();

  function bundle(ids) {
    $.util.log('Compiling JS...');
    if (ids) {
      console.log('Chnaged Files:\n' + ids);
    }
    return b.bundle()
      .on('error', function(err) {
        $.util.log(err.message);
        browserSync.notify('Browerify Error!')
        this.emit('end')
      })
      .pipe(source('bundle.js'))
      .pipe(buffer())
      .pipe($.sourcemaps.init({loadMaps: true}))
      .pipe($.sourcemaps.write('./'))
      .pipe(gulp.dest('.tmp/scripts'))
      .pipe(browserSync.stream({once:true}));
  }
});

gulp.task('js', function() {
  const DEST = '.tmp/scripts/';

  const b = browserify({
    entries: 'client/main.js',
    debug: true,
    cache: {},
    packageCache: {},
    transform: [babelify, debowerify]
  });

  return b.bundle()
    .on('error', function(err) {
      $.util.log(err.message);
      this.emit('end')
    })
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe($.sourcemaps.init({loadMaps: true}))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest(DEST));
});

gulp.task('lint', function() {
  return gulp.src('client/**/*.js')
    .pipe($.eslint({
        extends: 'eslint:recommended',
        globals: {
          'd3': true,
          'ga': true,
          'fa': true
        },
        rules: {
          semi: [2, "always"]
        },
        envs: [
          'browser'
        ]
    }))
    .pipe($.eslint.format())
    .pipe($.eslint.failAfterError());
});

gulp.task('serve',
  gulp.parallel(
    'mustache', 'styles', 'scripts',

    function serve() {
    browserSync.init({
      server: {
        baseDir: ['.tmp', 'client'],
        routes: {
          '/bower_components': 'bower_components'
        }
      }
    });

    gulp.watch('client/**/*.{csv,svg,png,jpg}', browserSync.reload);
    gulp.watch('client/**/**/*.scss', gulp.parallel('styles'));
    gulp.watch(['views/**/*.mustache', 'model/*.json'], gulp.parallel('mustache'));
    //gulp.watch('client/**/*.js', gulp.parallel('lint'));
  })
);

gulp.task('serve:dist', function() {
  browserSync.init({
    server: {
      baseDir: ['dist'],
      routes: {
        '/bower_components': 'bower_components'
      }
    }
  });
});

/* build */
gulp.task('html', function() {
  return gulp.src('.tmp/index.html')
/*    .pipe($.useref({searchPath: ['.', '.tmp']}))
    .pipe($.if('*.js', $.uglify()))
    .pipe($.if('*.css', $.cssnano()))*/
    .pipe($.if('*.html', $.htmlReplace(config.static)))
    .pipe($.smoosher())
    .pipe(gulp.dest('dist'));
});

gulp.task('extras', function () {
  return gulp.src('client/**/*.csv', {
    dot: true
  })
  .pipe(gulp.dest('dist'));
});

gulp.task('images', function () {
  return gulp.src('client/images/*.{svg,png,jpg,jpeg,gif}')
    .pipe($.imagemin({
      progressive: true,
      interlaced: true,
      svgoPlugins: [{cleanupIDs: false}]
    }))
    .pipe(gulp.dest('dist/images'));
});

gulp.task('clean', function() {
  return del(['.tmp', 'dist']).then(()=>{
    console.log('.tmp and dist deleted');
  });
});

gulp.task('build', gulp.series('clean', gulp.parallel('mustache', 'styles', 'js', 'images', 'extras'), 'html'));

/**********deploy***********/
gulp.task('deploy:assets', function() {
  return gulp.src(['dist/**/*.{csv,png,jpg,svg}'])
    .pipe(gulp.dest(config.deploy.assets + projectName))
});

gulp.task('deploy:html', function() {
  return gulp.src('dist/index.html')
    .pipe($.prefix(config.prefixUrl + projectName))
    .pipe($.rename({basename: projectName, extname: '.html'}))
    .pipe($.htmlmin({
      removeComments: true,
      collapseWhitespace: true,
      removeAttributeQuotes: true,
      minifyJS: true,
      minifyCSS: true
    }))
    .pipe($.sizereport({
      gzip: true
    }))
    .pipe(gulp.dest(config.deploy.index));
});

gulp.task('deploy', gulp.series('build', gulp.parallel('deploy:assets', 'deploy:html')));

/* demos */
gulp.task("mustache:demos", function() {
  const DEST = '.tmp';

  const article = JSON.parse(fs.readFileSync('model/' + dataFile));

  const footer = JSON.parse(fs.readFileSync('model/footer.json'));

  return gulp.src('demos/*.mustache')
    .pipe($.changed(DEST))
    .pipe($.if('light-theme.mustache',
      $.mustache({
        theme: true,
        article: article,
        footer: footer
      }, {
        extension: '.html'
      }),
      $.mustache({
        theme: false,
        article: article,
        footer: footer
      }, {
        extension: '.html'
      })
    ))
    .pipe(gulp.dest(DEST))
    .pipe(browserSync.stream({once: true}));
});

gulp.task('copy:demos', function() {
  return gulp.src('demos/index.html')
    .pipe(gulp.dest('.tmp'))
    .pipe(browserSync.stream({once: true}));
});

gulp.task('images:demos', function() {
  return gulp.src('client/images/*.{svg,png,jpg,jpeg,gif}')
    .pipe($.imagemin({
      progressive: true,
      interlaced: true,
      svgoPlugins: [{cleanupIDs: false}]
    }))
    .pipe(gulp.dest('.tmp/images'));
});

gulp.task('build:demos', gulp.parallel('copy:demos', 'mustache:demos', 'styles', 'images:demos'));

gulp.task('watch:demos',
  gulp.parallel('copy:demos', 'mustache:demos', 'styles',
    function serve() {
    browserSync.init({
      server: {
        baseDir: ['demos', '.tmp', 'client'],
        routes: {
          '/bower_components': 'bower_components'
        }
      }
    });

    gulp.watch('client/**/*.{csv,svg,png,jpg}', browserSync.reload);
    gulp.watch('client/**/**/*.scss', gulp.parallel('styles'));
    gulp.watch('demos/*.html', gulp.parallel('copy:demos'));
    gulp.watch(['views/**/*.mustache', 'model/*.json', 'demos/*.mustache'], gulp.parallel('mustache:demos'));
    //gulp.watch('client/**/*.js', gulp.parallel('lint'));
  })
);

gulp.task('demos', gulp.series('clean', 'build:demos', function(){
  return gulp.src('.tmp/**/**')
    .pipe(gulp.dest(config.deploy.assets + projectName));
}));<|endoftext|>


<commit_before>var del = require('del'),
	gulp = require('gulp'),
	gutil = require('gulp-util'),
	browserify = require('browserify'),
	watchify = require('watchify'),
	reactify = require('reactify'),
	source = require('vinyl-source-stream'),
	merge = require('merge-stream'),
	chalk = require('chalk');

/**
 * Clean Everything
 */

gulp.task('clean', function(done) {
	del(['./examples/public/build'], done);
});

/**
 * Build Examples
 */

function doBundle(target, name, dest) {
	return target.bundle()
		.on('error', function(e) {
			gutil.log('Browserify Error', e);
		})
		.pipe(source(name))
		.pipe(gulp.dest(dest));
}

function watchBundle(target, name, dest) {
	doBundle(target, name, dest);
	return watchify(target)
		.on('update', function (scriptIds) {
			scriptIds = scriptIds
			.filter(function(i) { return i.substr(0,2) !== './' })
				.map(function(i) { return chalk.blue(i.replace(__dirname, '')) });
			if (scriptIds.length > 1) {
				gutil.log(scriptIds.length + ' Scripts updated:\n* ' + scriptIds.join('\n* ') + '\nrebuilding...');
			} else {
				gutil.log(scriptIds[0] + ' updated, rebuilding...');
			}
			doBundle(target, name, dest);
		})
		.on('time', function (time) {
			gutil.log(chalk.green(name + ' built in ' + (Math.round(time / 10) / 100) + 's'));
		});
}

function buildExamples(watch) {

	var ops = watch ? watchify.args : {};

	var dest = './examples/public/build';

	var app = browserify(ops)
		.add('./examples/src/app.js')
		.exclude('react')
		.exclude('react-select')
		.transform(reactify);

	var common = browserify(ops)
		.require('react')
		.require('./lib/select.js', { expose: 'react-select' });

	if (watch) {
		watchBundle(app, 'app-bundle.js', dest);
		watchBundle(common, 'global-bundle.js', dest);
	} else {
		return merge(
			doBundle(app, 'app-bundle.js', dest),
			doBundle(common, 'global-bundle.js', dest)
		);
	}

}

gulp.task('build-examples', ['clean'], function() {
	return buildExamples();
});

gulp.task('watch-examples', ['clean'], function() {
	return buildExamples(true);
});
<commit_msg>Adding less build task for gulp<commit_after>var del = require('del'),
	gulp = require('gulp'),
	gutil = require('gulp-util'),
	less = require('gulp-less'),
	browserify = require('browserify'),
	watchify = require('watchify'),
	reactify = require('reactify'),
	source = require('vinyl-source-stream'),
	merge = require('merge-stream'),
	chalk = require('chalk');

/**
 * Clean Everything
 */

gulp.task('clean', function(done) {
	del(['./examples/public/build'], done);
});

/**
 * Build Default theme from LESS
 */

gulp.task('less', function() {
	return gulp.src('less/default.less')
		.pipe(less())
		.pipe(gulp.dest('dist'));
});

/**
 * Build Examples
 */

function doBundle(target, name, dest) {
	return target.bundle()
		.on('error', function(e) {
			gutil.log('Browserify Error', e);
		})
		.pipe(source(name))
		.pipe(gulp.dest(dest));
}

function watchBundle(target, name, dest) {
	doBundle(target, name, dest);
	return watchify(target)
		.on('update', function (scriptIds) {
			scriptIds = scriptIds
			.filter(function(i) { return i.substr(0,2) !== './' })
				.map(function(i) { return chalk.blue(i.replace(__dirname, '')) });
			if (scriptIds.length > 1) {
				gutil.log(scriptIds.length + ' Scripts updated:\n* ' + scriptIds.join('\n* ') + '\nrebuilding...');
			} else {
				gutil.log(scriptIds[0] + ' updated, rebuilding...');
			}
			doBundle(target, name, dest);
		})
		.on('time', function (time) {
			gutil.log(chalk.green(name + ' built in ' + (Math.round(time / 10) / 100) + 's'));
		});
}

function buildExamples(watch) {

	var ops = watch ? watchify.args : {};

	var dest = './examples/public/build';

	var app = browserify(ops)
		.add('./examples/src/app.js')
		.exclude('react')
		.exclude('react-select')
		.transform(reactify);

	var common = browserify(ops)
		.require('react')
		.require('./lib/select.js', { expose: 'react-select' });

	if (watch) {
		watchBundle(app, 'app-bundle.js', dest);
		watchBundle(common, 'global-bundle.js', dest);
	} else {
		return merge(
			doBundle(app, 'app-bundle.js', dest),
			doBundle(common, 'global-bundle.js', dest)
		);
	}

}

gulp.task('build-examples', ['clean'], function() {
	return buildExamples();
});

gulp.task('watch-examples', ['clean'], function() {
	return buildExamples(true);
});
<|endoftext|>


<commit_before>'use strict';

let gulp = require('gulp'),
    // Компилятор LESS
    less = require('gulp-less'),
    // Карта исходников
    sourcemaps = require('gulp-sourcemaps'),
    // Вендорные префиксы
    autoprefixer = require('gulp-autoprefixer'),
    // Конкатенация файлов
    concat = require('gulp-concat'),
    // Watcher custom
    watch = require('gulp-watch'),
    // Ловим ошибки
    plumber = require('gulp-plumber'),
    // Уведомления
    notify = require('gulp-notify'),
    // JS Валидатор
    jsValidate = require('gulp-jsvalidate'),
    // IMG Min
    imagemin = require('gulp-imagemin'),
    // HTML Validator
    htmlhint = require('gulp-htmlhint'),
    // Min CSS
    cleanCss = require('gulp-clean-css'),
    // Web Server
    connect = require('gulp-connect');

let path = {

    build: {
        html: 'build/',
        style: 'build/css/',
        js: 'build/js/',
        img: 'build/img/',
        fonts: 'build/fonts/',
        files: 'build/files/'
    },
    src: {
        html: 'src/html/*.html',
        style: 'src/less/index.less',
        js: 'src/js/*.js',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*',
        files: 'src/files/**/*.*'
    },
    watch: {
        html: 'src/html/**/*.html',
        style: 'src/less/**/*.less',
        js: 'src/js/*.js',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*',
        files: 'src/files/**/*.*'
    }
}

let config = {

    server: {
        root: 'build',
        port: 8000,
        livereload: true
    }
}

let mess = {

    html: {
        success: "HTML Compilation Done",
        error: "Error: <%= error.message %>"
    },
    style: {
        success: "Less Compilation Done",
        error: "Error: <%= error.message %>"
    },
    js: {
        success: "JS Compilation Done",
        error: "Error: <%= error.message %>"
    },
    image: {
        success: "IMAGES Compilation Done",
        error: "Error: <%= error.message %>"
    },
    fonts: {
        success: "FONTS Compilation Done",
        error: "Error: <%= error.message %>"
    },
    files: {
        success: "FILES Compilation Done",
        error: "Error: <%= error.message %>"
    }

}

gulp.task('server:build', function () {
    connect.server(config.server);
});

// BUILD //
gulp.task('style:build', function () {
    return watch(path.watch.style, function(){
        gulp.src(path.src.style)
        .pipe(plumber({errorHandler: notify.onError(mess.style.error)}))
        .pipe(sourcemaps.init())
        .pipe(less())
        .pipe(autoprefixer({
            browsers: ['last 50 versions']
        }))
        .pipe(concat('style.css'))
        .pipe(cleanCss({compatibility: 'ie8'}))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(path.build.style))
        .pipe(notify(mess.style.success))
        .pipe(connect.reload());
    });
});

gulp.task('js:build', function () {
    return watch(path.watch.js, function(){
        gulp.src(path.src.js)
        .pipe(plumber({errorHandler: notify.onError(mess.js.error)}))
        .pipe(jsValidate())
        .pipe(notify(mess.js.success))
        .pipe(sourcemaps.init())
        .pipe(gulp.dest(path.build.js+'paths'))
        .pipe(concat('script.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(path.build.js))
        .pipe(connect.reload());

    });
});

gulp.task('image:build', function () {
    return watch(path.watch.img, function(){
        gulp.src(path.src.img)
        .pipe(plumber())
        .pipe(imagemin({
            interlaced: true,
            progressive: true,
            optimizationLevel: 5,
            svgoPlugins: [{removeViewBox: true}]
        }))
        .pipe(gulp.dest(path.build.img))
        .pipe(notify(mess.image.success))
        .pipe(connect.reload());

    });
});

gulp.task('html:build', function () {
    return watch(path.watch.html, function(){
        gulp.src(path.src.html)
        .pipe(plumber())
        .pipe(htmlhint({
            "attr-value-not-empty": true,
            "attr-no-duplication": true,
            "tag-pair": true,
            "id-unique": true,
            "doctype-html5": true,
        }))
        .pipe(htmlhint.reporter())
        .pipe(gulp.dest(path.build.html))
        .pipe(notify(mess.html.success))
        .pipe(connect.reload());

    });
});

gulp.task('fonts:build', function () {
    return watch(path.watch.fonts, function(){
        gulp.src(path.src.fonts)
        .pipe(gulp.dest(path.build.fonts))
        .pipe(notify(mess.fonts.success))
        .pipe(connect.reload());
    });
});

gulp.task('files:build', function () {
    return watch(path.watch.files, function(){
        gulp.src(path.src.files)
        .pipe(gulp.dest(path.build.files))
        .pipe(notify(mess.files.success))
        .pipe(connect.reload());
    });
});

gulp.task('build', [
    'server:build',
    'html:build',
    'js:build',
    'style:build',
    'fonts:build',
    'image:build',
    'files:build'
]);

<commit_msg>Обновление Gulpfile.js<commit_after>'use strict';

let gulp = require('gulp'),
    // Компилятор LESS
    less = require('gulp-less'),
    // Карта исходников
    sourcemaps = require('gulp-sourcemaps'),
    // Вендорные префиксы
    autoprefixer = require('gulp-autoprefixer'),
    // Конкатенация файлов
    concat = require('gulp-concat'),
    // Watcher custom
    watch = require('gulp-watch'),
    // Ловим ошибки
    plumber = require('gulp-plumber'),
    // Уведомления
    notify = require('gulp-notify'),
    // JS Валидатор
    jsValidate = require('gulp-jsvalidate'),
    // IMG Min
    imagemin = require('gulp-imagemin'),
    // HTML Validator
    htmlhint = require('gulp-htmlhint'),
    // Min CSS
    cleanCss = require('gulp-clean-css'),
    // Web Server
    connect = require('gulp-connect');

let path = {

    build: {
        html: 'build/',
        style: 'build/css/',
        js: 'build/js/',
        img: 'build/img/',
        fonts: 'build/fonts/',
        files: 'build/files/',
        libs: 'build/libs/'
    },
    src: {
        html: 'src/html/*.html',
        style: 'src/less/index.less',
        js: 'src/js/*.js',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*',
        files: 'src/files/**/*.*',
        libs: 'src/libs/**/*.*'
    },
    watch: {
        html: 'src/html/**/*.html',
        style: 'src/less/**/*.less',
        js: 'src/js/*.js',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*',
        files: 'src/files/**/*.*',
        libs: 'src/libs/**/*.*'
    }
}

let config = {

    server: {
        root: 'build',
        port: 8000,
        livereload: true
    }
}

let mess = {

    html: {
        success: "HTML Compilation Done",
        error: "Error: <%= error.message %>"
    },
    style: {
        success: "Less Compilation Done",
        error: "Error: <%= error.message %>"
    },
    js: {
        success: "JS Compilation Done",
        error: "Error: <%= error.message %>"
    },
    image: {
        success: "IMAGES Compilation Done",
        error: "Error: <%= error.message %>"
    },
    fonts: {
        success: "FONTS Compilation Done",
        error: "Error: <%= error.message %>"
    },
    files: {
        success: "FILES Compilation Done",
        error: "Error: <%= error.message %>"
    }
    libs: {
        success: "LIBS Compilation Done",
        error: "Error: <%= error.message %>"
    }

}

gulp.task('server:build', function () {
    connect.server(config.server);
});

// BUILD //
gulp.task('style:build', function () {
    return watch(path.watch.style, function(){
        gulp.src(path.src.style)
        .pipe(plumber({errorHandler: notify.onError(mess.style.error)}))
        .pipe(sourcemaps.init())
        .pipe(less())
        .pipe(autoprefixer({
            browsers: ['last 50 versions']
        }))
        .pipe(concat('style.css'))
        .pipe(cleanCss({compatibility: 'ie8'}))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(path.build.style))
        .pipe(notify(mess.style.success))
        .pipe(connect.reload());
    });
});

gulp.task('js:build', function () {
    return watch(path.watch.js, function(){
        gulp.src(path.src.js)
        .pipe(plumber({errorHandler: notify.onError(mess.js.error)}))
        .pipe(jsValidate())
        .pipe(notify(mess.js.success))
        .pipe(sourcemaps.init())
        .pipe(gulp.dest(path.build.js+'paths'))
        .pipe(concat('script.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(path.build.js))
        .pipe(connect.reload());

    });
});

gulp.task('image:build', function () {
    return watch(path.watch.img, function(){
        gulp.src(path.src.img)
        .pipe(plumber())
        .pipe(imagemin({
            interlaced: true,
            progressive: true,
            optimizationLevel: 5,
            svgoPlugins: [{removeViewBox: true}]
        }))
        .pipe(gulp.dest(path.build.img))
        .pipe(notify(mess.image.success))
        .pipe(connect.reload());

    });
});

gulp.task('html:build', function () {
    return watch(path.watch.html, function(){
        gulp.src(path.src.html)
        .pipe(plumber())
        .pipe(htmlhint({
            "attr-value-not-empty": true,
            "attr-no-duplication": true,
            "tag-pair": true,
            "id-unique": true,
            "doctype-html5": true,
        }))
        .pipe(htmlhint.reporter())
        .pipe(gulp.dest(path.build.html))
        .pipe(notify(mess.html.success))
        .pipe(connect.reload());

    });
});

gulp.task('fonts:build', function () {
    return watch(path.watch.fonts, function(){
        gulp.src(path.src.fonts)
        .pipe(gulp.dest(path.build.fonts))
        .pipe(notify(mess.fonts.success))
        .pipe(connect.reload());
    });
});

gulp.task('files:build', function () {
    return watch(path.watch.files, function(){
        gulp.src(path.src.files)
        .pipe(gulp.dest(path.build.files))
        .pipe(notify(mess.files.success))
        .pipe(connect.reload());
    });
});

gulp.task('libs:build', function () {
    return watch(path.watch.libs, function(){
        gulp.src(path.src.libs)
        .pipe(gulp.dest(path.build.libs))
        .pipe(notify(mess.libs.success))
        .pipe(connect.reload());
    });
});

gulp.task('build', [
    'server:build',
    'html:build',
    'js:build',
    'style:build',
    'fonts:build',
    'image:build',
    'files:build',
    'libs:build'
]);

<|endoftext|>


<commit_before>const gulp = require('gulp');

// Pug
const pug = require('gulp-pug');
const fs = require('fs');
const data = require('gulp-data');
const path = require('path');

// HTML
const htmlhint = require('gulp-htmlhint');
const w3cjs = require('gulp-w3cjs');
const browserSyncSsi = require('browsersync-ssi');

// CSS
const sass = require('gulp-sass');
const sassGlob = require('gulp-sass-glob');
const postcss = require('gulp-postcss');
const flexBugsFixes = require('postcss-flexbugs-fixes');
const autoprefixer = require('autoprefixer');
const cleanCSS = require('gulp-clean-css');
const gulpStylelint = require('gulp-stylelint');

// JS
const webpackStream = require('webpack-stream');

// Image
const imagemin = require('gulp-imagemin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const imageminPngquant = require('imagemin-pngquant');

// SVG sprite
const gulpSvgSprite = require('gulp-svg-sprite');

// Styleguide
const aigis = require('gulp-aigis');

// Utility
const cache = require('gulp-cached');
const changed = require('gulp-changed');
const browserSync = require('browser-sync');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const gulpif = require('gulp-if');
const del = require('del');

/**
 * 開発用ディレクトリ
 */
const src = {
  root: 'src/',
  html: ['src/**/*.pug', '!src/**/_*.pug'],
  htmlWatch: 'src/**/*.pug',
  ssi: 'static/**/*.html',
  data: 'src/_data/',
  css: 'src/**/*.scss',
  styleguideWatch: ['src/**/*.scss', 'src/**/*.md'],
  js: './src/assets/js/site.js',
  jsWatch: 'src/**/*.{js,vue}',
  image: 'src/assets/img/**/*.{png,jpg,gif,svg}',
  imageWatch: 'src/assets/img/**/*',
  svgSprite: 'src/assets/svg/**/*.svg',
  copy: 'static/**/*',
};

/**
 * 公開用ディレクトリ
 */
const dest = {
  root: 'htdocs/',
  image: 'htdocs/assets/img/',
  js: 'assets/js/',
  svgSprite: 'htdocs/assets/svg/',
  cleanDest: 'htdocs/',
};

/**
 * 環境変数を設定します。
 * npmスクリプトから`APP_ENV=development`かAPP_ENV=production`を受け取れます。
 */
const env = process.env.APP_ENV;
const developmentValues = require('./config/development').defaults;
const productionValues = require('./config/production').defaults;

const envValues = env === 'development' ? developmentValues : productionValues;
const isDevelopment = envValues.NODE_ENV === 'development';
const isProduction = envValues.NODE_ENV === 'production';

/**
 * `.pug`を`.html`にコンパイルします。
 * JSONとページごとのルート相対パスの格納、ルート相対パスを使ったincludeの設定をします。
 */
function html() {
  // JSONファイルの読み込み。
  const locals = {
    site: JSON.parse(fs.readFileSync(`${src.data}site.json`)),
  };
  locals.ja = {
    // 日本語サイト共通のデータです。
    site: JSON.parse(fs.readFileSync(`${src.data}ja/site.json`)),
  };
  locals.en = {
    // 英語サイト共通のデータです。
    site: JSON.parse(fs.readFileSync(`${src.data}en/site.json`)),
  };
  return (
    gulp
      .src(src.html)
      // エラーでタスクを止めない
      .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
      .pipe(
        data(file => {
          // 各ページのルート相対パスを格納します。
          locals.pageAbsolutePath = `/${path
            .relative(file.base, file.path.replace(/.pug$/, '.html'))
            .replace(/index\.html$/, '')}`;
          return locals;
        }),
      )
      .pipe(cache('html'))
      .pipe(
        pug({
          // `locals`に渡したデータを各Pugファイルで取得できます。
          locals,
          // ルート相対パスでincludeが使えるようにします。
          basedir: 'src',
          // Pugファイルの整形。
          pretty: true,
        }),
      )
      .pipe(gulp.dest(dest.root))
      .pipe(browserSync.reload({ stream: true }))
  );
}

/**
 * 公開用のHTMLファイルを解析して警告やエラーを通知します。
 */
function htmlValidate() {
  // 範囲を限定する場合は`products/`などと指定します。
  const validateDir = '';
  return gulp
    .src([`${dest.root}${validateDir}**/*.html`, `!${dest.root}styleguide/**/*.html`])
    .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
    .pipe(htmlhint('.htmlhintrc'))
    .pipe(htmlhint.reporter('htmlhint-stylish'))
    .pipe(
      w3cjs({
        // Warningも表示する
        // showInfo: true,
      }),
    )
    .pipe(
      htmlhint.failOnError({
        suppress: true,
      }),
    );
}

/**
 * /static/以下のHTMLファイルを監視、更新があれば反映します。
 */
function ssi() {
  return gulp.src(src.ssi).pipe(browserSync.reload({ stream: true }));
}

/**
 * 公開用のSassファイルを解析して警告やエラーを通知します。
 * 修正できるものは強制的に反映します。
 */
function stylelint() {
  return gulp
    .src(src.css)
    .pipe(
      gulpStylelint({
        fix: true,
        reporters: [{ formatter: 'string', console: true }],
      }),
    )
    .pipe(gulp.dest(src.root));
}

/**
 * `.scss`を`.css`にコンパイルします。
 */
function css() {
  const plugins = [flexBugsFixes(), autoprefixer()];
  return (
    gulp
      .src(src.css, {
        sourcemaps: !!isDevelopment,
      })
      // globパターンでのインポート機能を追加
      .pipe(sassGlob())
      .pipe(
        sass({
          outputStyle: 'expanded',
        }).on('error', sass.logError),
      )
      .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
      .pipe(postcss(plugins))
      .pipe(
        gulpif(
          isDevelopment,
          cleanCSS({
            // 圧縮せずに整形して出力する
            format: 'beautify',
            compatibility: {
              properties: {
                // 0の単位を不必要な場合は削除する
                zeroUnits: false,
              },
            },
          }),
        ),
      )
      .pipe(
        gulpif(
          isProduction,
          cleanCSS({
            compatibility: {
              properties: {
                // 0の単位を不必要な場合は削除する
                zeroUnits: false,
              },
            },
          }),
        ),
      )
      .pipe(
        gulp.dest(dest.root, {
          sourcemaps: !!isDevelopment,
        }),
      )
      .pipe(browserSync.reload({ stream: true }))
  );
}

/**
 * ES2015以降のコードをES5に変換（トランスコンパイル）します。
 * Vue.jsの単一ファイルコンポーネントの変換と、ESLint・Prettierも実行します。
 */
function js() {
  const VueLoaderPlugin = require('vue-loader/lib/plugin');
  return gulp
    .src(src.js)
    .pipe(
      webpackStream({
        mode: envValues.NODE_ENV,
        entry: {
          site: src.js,
        },
        module: {
          rules: [
            {
              test: /\.vue$/,
              loader: 'vue-loader',
            },
            {
              test: /\.js$/,
              loader: 'babel-loader',
            },
            {
              enforce: 'pre',
              test: /\.(js|vue)$/,
              exclude: /node_modules/,
              loader: 'eslint-loader',
              options: {
                fix: true,
                formatter: require('eslint/lib/cli-engine/formatters/stylish'),
              },
            },
            {
              test: /\.(scss$|css$)/,
              use: ['vue-style-loader', 'css-loader', 'sass-loader'],
            },
          ],
        },
        resolve: {
          alias: {
            vue$: 'vue/dist/vue.esm.js',
          },
        },
        plugins: [new VueLoaderPlugin()],
        output: {
          filename: `${dest.js}[name].js`,
        },
      }),
    )
    .pipe(gulp.dest(dest.root))
    .pipe(browserSync.reload({ stream: true }));
}

/**
 * 画像を圧縮します。
 */
function image() {
  return gulp
    .src(src.image)
    .pipe(changed(dest.image))
    .pipe(
      plumber({
        errorHandler(err) {
          // eslint-disable-next-line no-console
          console.log(err.messageFormatted);
          this.emit('end');
        },
      }),
    )
    .pipe(
      imagemin([
        imageminMozjpeg({
          // 画質
          quality: 70,
        }),
        imageminPngquant({
          // 画質
          quality: [0.7, 0.8],
        }),
        imagemin.svgo({
          plugins: [
            // viewBox属性を削除する（widthとheight属性がある場合）。
            // 表示が崩れる原因になるので削除しない。
            { removeViewBox: false },
            // <metadata>を削除する。
            // 追加したmetadataを削除する必要はない。
            { removeMetadata: false },
            // SVGの仕様に含まれていないタグや属性、id属性やvertion属性を削除する。
            // 追加した要素を削除する必要はない。
            { removeUnknownsAndDefaults: false },
            // コードが短くなる場合だけ<path>に変換する。
            // アニメーションが動作しない可能性があるので変換しない。
            { convertShapeToPath: false },
            // 重複や不要な`<g>`タグを削除する。
            // アニメーションが動作しない可能性があるので変換しない。
            { collapseGroups: false },
            // SVG内に<style>や<script>がなければidを削除する。
            // idにアンカーが貼られていたら削除せずにid名を縮小する。
            // id属性は動作の起点となることがあるため削除しない。
            { cleanupIDs: false },
          ],
        }),
        imagemin.optipng(),
        imagemin.gifsicle(),
      ]),
    )
    .pipe(gulp.dest(dest.image))
    .pipe(browserSync.reload({ stream: true }));
}

/**
 * SVGファイルからSVGスプライトを生成します。
 */
function svgSprite() {
  return gulp
    .src(src.svgSprite)
    .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
    .pipe(
      gulpSvgSprite({
        mode: {
          // SVGファイルをsymbol要素としてまとめる。
          symbol: {
            dest: './',
            // 出力するファイル名。
            sprite: 'sprite.svg',
          },
        },
        shape: {
          transform: [
            {
              svgo: {
                plugins: [
                  // `style`属性を削除する。
                  { removeStyleElement: true },
                  // `fill`属性を削除して、CSSで`fill`の変更ができるようにする。
                  { removeAttrs: { attrs: 'fill' } },
                ],
              },
            },
          ],
        },
        svg: {
          // xml宣言を出力する。
          xmlDeclaration: false,
          // DOCTYPE宣言を出力する。
          doctypeDeclaration: false,
        },
      }),
    )
    .pipe(gulp.dest(dest.svgSprite))
    .pipe(browserSync.reload({ stream: true }));
}

/**
 * スタイルガイドを生成します。
 * aigisは開発が止まっているので、別のスタイルガイドジェネレーターを検討してください。
 */
function styleguide() {
  return gulp.src('./aigis/aigis_config.yml').pipe(aigis());
}

/**
 * Gulpの処理を通さないディレクトリです。
 * 公開用のディレクトリにコピーします。
 */
function copy() {
  return gulp.src(src.copy).pipe(gulp.dest(dest.root));
}

/**
 * ローカルサーバーを起動します。
 */
function serve(done) {
  browserSync({
    server: {
      // SSIを使用します。
      // middleware: [
      //   browserSyncSsi({
      //     baseDir: dest.root,
      //     ext: '.html',
      //   }),
      // ],
      baseDir: dest.root,
    },
    // 画面を共有するときにスクロールやクリックなどをミラーリングしたくない場合はfalseにします。
    ghostMode: false,
    // ローカルIPアドレスでサーバーを立ち上げます。
    open: 'external',
    // サーバー起動時に表示するページを指定します。
    startPath: '/styleguide/',
    // falseに指定すると、サーバー起動時にポップアップを表示させません。
    notify: false,
  });
  done();
}

/**
 * 公開用のディレクトリを削除します。
 */
function clean() {
  return del(dest.cleanDest);
}

/**
 * publicなgulpタスクです。
 * `gulp html`のように実行できます。
 */
exports.html = html;
exports.htmlValidate = htmlValidate;
exports.ssi = ssi;
exports.stylelint = stylelint;
exports.css = css;
exports.js = js;
exports.image = image;
exports.svgSprite = svgSprite;
exports.styleguide = styleguide;
exports.copy = copy;
exports.serve = serve;
exports.clean = clean;

/**
 * ファイルを監視します。
 */
function watch() {
  gulp.watch(src.htmlWatch, html);
  gulp.watch(src.imageWatch, image);
  gulp.watch(src.ssi, ssi);
  gulp.watch(src.css, css);
  gulp.watch(src.jsWatch, js);
  gulp.watch(src.svgSprite, svgSprite);
  gulp.watch(src.styleguideWatch, styleguide);
  gulp.watch(src.copy, copy);
}

/**
 * 開発タスクをすべて実行します。
 */
exports.build = gulp.series(
  gulp.parallel(clean),
  html,
  ssi,
  css,
  styleguide,
  js,
  image,
  svgSprite,
  copy,
);

/**
 * 開発タスクをすべて実行します。
 * ローカルサーバーを起動し、リアルタイムに更新を反映させます。
 */
exports.default = gulp.series(
  gulp.parallel(clean),
  html,
  ssi,
  css,
  styleguide,
  js,
  image,
  svgSprite,
  copy,
  gulp.parallel(serve, watch),
);
<commit_msg>Fix: タイポ<commit_after>const gulp = require('gulp');

// Pug
const pug = require('gulp-pug');
const fs = require('fs');
const data = require('gulp-data');
const path = require('path');

// HTML
const htmlhint = require('gulp-htmlhint');
const w3cjs = require('gulp-w3cjs');
const browserSyncSsi = require('browsersync-ssi');

// CSS
const sass = require('gulp-sass');
const sassGlob = require('gulp-sass-glob');
const postcss = require('gulp-postcss');
const flexBugsFixes = require('postcss-flexbugs-fixes');
const autoprefixer = require('autoprefixer');
const cleanCSS = require('gulp-clean-css');
const gulpStylelint = require('gulp-stylelint');

// JS
const webpackStream = require('webpack-stream');

// Image
const imagemin = require('gulp-imagemin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const imageminPngquant = require('imagemin-pngquant');

// SVG sprite
const gulpSvgSprite = require('gulp-svg-sprite');

// Styleguide
const aigis = require('gulp-aigis');

// Utility
const cache = require('gulp-cached');
const changed = require('gulp-changed');
const browserSync = require('browser-sync');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const gulpif = require('gulp-if');
const del = require('del');

/**
 * 開発用ディレクトリ
 */
const src = {
  root: 'src/',
  html: ['src/**/*.pug', '!src/**/_*.pug'],
  htmlWatch: 'src/**/*.pug',
  ssi: 'static/**/*.html',
  data: 'src/_data/',
  css: 'src/**/*.scss',
  styleguideWatch: ['src/**/*.scss', 'src/**/*.md'],
  js: './src/assets/js/site.js',
  jsWatch: 'src/**/*.{js,vue}',
  image: 'src/assets/img/**/*.{png,jpg,gif,svg}',
  imageWatch: 'src/assets/img/**/*',
  svgSprite: 'src/assets/svg/**/*.svg',
  copy: 'static/**/*',
};

/**
 * 公開用ディレクトリ
 */
const dest = {
  root: 'htdocs/',
  image: 'htdocs/assets/img/',
  js: 'assets/js/',
  svgSprite: 'htdocs/assets/svg/',
  cleanDest: 'htdocs/',
};

/**
 * 環境変数を設定します。
 * npmスクリプトから`APP_ENV=development`かAPP_ENV=production`を受け取れます。
 */
const env = process.env.APP_ENV;
const developmentValues = require('./config/development').defaults;
const productionValues = require('./config/production').defaults;

const envValues = env === 'development' ? developmentValues : productionValues;
const isDevelopment = envValues.NODE_ENV === 'development';
const isProduction = envValues.NODE_ENV === 'production';

/**
 * `.pug`を`.html`にコンパイルします。
 * JSONとページごとのルート相対パスの格納、ルート相対パスを使ったincludeの設定をします。
 */
function html() {
  // JSONファイルの読み込み。
  const locals = {
    site: JSON.parse(fs.readFileSync(`${src.data}site.json`)),
  };
  locals.ja = {
    // 日本語サイト共通のデータです。
    site: JSON.parse(fs.readFileSync(`${src.data}ja/site.json`)),
  };
  locals.en = {
    // 英語サイト共通のデータです。
    site: JSON.parse(fs.readFileSync(`${src.data}en/site.json`)),
  };
  return (
    gulp
      .src(src.html)
      // エラーでタスクを止めない
      .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
      .pipe(
        data(file => {
          // 各ページのルート相対パスを格納します。
          locals.pageAbsolutePath = `/${path
            .relative(file.base, file.path.replace(/.pug$/, '.html'))
            .replace(/index\.html$/, '')}`;
          return locals;
        }),
      )
      .pipe(cache('html'))
      .pipe(
        pug({
          // `locals`に渡したデータを各Pugファイルで取得できます。
          locals,
          // ルート相対パスでincludeが使えるようにします。
          basedir: 'src',
          // Pugファイルの整形。
          pretty: true,
        }),
      )
      .pipe(gulp.dest(dest.root))
      .pipe(browserSync.reload({ stream: true }))
  );
}

/**
 * 公開用のHTMLファイルを解析して警告やエラーを通知します。
 */
function htmlValidate() {
  // 範囲を限定する場合は`products/`などと指定します。
  const validateDir = '';
  return gulp
    .src([`${dest.root}${validateDir}**/*.html`, `!${dest.root}styleguide/**/*.html`])
    .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
    .pipe(htmlhint('.htmlhintrc'))
    .pipe(htmlhint.reporter('htmlhint-stylish'))
    .pipe(
      w3cjs({
        // Warningも表示する
        // showInfo: true,
      }),
    )
    .pipe(
      htmlhint.failOnError({
        suppress: true,
      }),
    );
}

/**
 * /static/以下のHTMLファイルを監視、更新があれば反映します。
 */
function ssi() {
  return gulp.src(src.ssi).pipe(browserSync.reload({ stream: true }));
}

/**
 * 公開用のSassファイルを解析して警告やエラーを通知します。
 * 修正できるものは強制的に反映します。
 */
function stylelint() {
  return gulp
    .src(src.css)
    .pipe(
      gulpStylelint({
        fix: true,
        reporters: [{ formatter: 'string', console: true }],
      }),
    )
    .pipe(gulp.dest(src.root));
}

/**
 * `.scss`を`.css`にコンパイルします。
 */
function css() {
  const plugins = [flexBugsFixes(), autoprefixer()];
  return (
    gulp
      .src(src.css, {
        sourcemaps: !!isDevelopment,
      })
      // globパターンでのインポート機能を追加
      .pipe(sassGlob())
      .pipe(
        sass({
          outputStyle: 'expanded',
        }).on('error', sass.logError),
      )
      .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
      .pipe(postcss(plugins))
      .pipe(
        gulpif(
          isDevelopment,
          cleanCSS({
            // 圧縮せずに整形して出力する
            format: 'beautify',
            compatibility: {
              properties: {
                // 0の単位を不必要な場合は削除する
                zeroUnits: false,
              },
            },
          }),
        ),
      )
      .pipe(
        gulpif(
          isProduction,
          cleanCSS({
            compatibility: {
              properties: {
                // 0の単位を不必要な場合は削除する
                zeroUnits: false,
              },
            },
          }),
        ),
      )
      .pipe(
        gulp.dest(dest.root, {
          sourcemaps: !!isDevelopment,
        }),
      )
      .pipe(browserSync.reload({ stream: true }))
  );
}

/**
 * ES2015以降のコードをES5に変換（トランスコンパイル）します。
 * Vue.jsの単一ファイルコンポーネントの変換と、ESLint・Prettierも実行します。
 */
function js() {
  const VueLoaderPlugin = require('vue-loader/lib/plugin');
  return gulp
    .src(src.js)
    .pipe(
      webpackStream({
        mode: envValues.NODE_ENV,
        entry: {
          site: src.js,
        },
        module: {
          rules: [
            {
              test: /\.vue$/,
              loader: 'vue-loader',
            },
            {
              test: /\.js$/,
              loader: 'babel-loader',
            },
            {
              enforce: 'pre',
              test: /\.(js|vue)$/,
              exclude: /node_modules/,
              loader: 'eslint-loader',
              options: {
                fix: true,
                formatter: require('eslint/lib/cli-engine/formatters/stylish'),
              },
            },
            {
              test: /\.(scss$|css$)/,
              use: ['vue-style-loader', 'css-loader', 'sass-loader'],
            },
          ],
        },
        resolve: {
          alias: {
            vue$: 'vue/dist/vue.esm.js',
          },
        },
        plugins: [new VueLoaderPlugin()],
        output: {
          filename: `${dest.js}[name].js`,
        },
      }),
    )
    .pipe(gulp.dest(dest.root))
    .pipe(browserSync.reload({ stream: true }));
}

/**
 * 画像を圧縮します。
 */
function image() {
  return gulp
    .src(src.image)
    .pipe(changed(dest.image))
    .pipe(
      plumber({
        errorHandler(err) {
          // eslint-disable-next-line no-console
          console.log(err.messageFormatted);
          this.emit('end');
        },
      }),
    )
    .pipe(
      imagemin([
        imageminMozjpeg({
          // 画質
          quality: 70,
        }),
        imageminPngquant({
          // 画質
          quality: [0.7, 0.8],
        }),
        imagemin.svgo({
          plugins: [
            // viewBox属性を削除する（widthとheight属性がある場合）。
            // 表示が崩れる原因になるので削除しない。
            { removeViewBox: false },
            // <metadata>を削除する。
            // 追加したmetadataを削除する必要はない。
            { removeMetadata: false },
            // SVGの仕様に含まれていないタグや属性、id属性やversion属性を削除する。
            // 追加した要素を削除する必要はない。
            { removeUnknownsAndDefaults: false },
            // コードが短くなる場合だけ<path>に変換する。
            // アニメーションが動作しない可能性があるので変換しない。
            { convertShapeToPath: false },
            // 重複や不要な`<g>`タグを削除する。
            // アニメーションが動作しない可能性があるので変換しない。
            { collapseGroups: false },
            // SVG内に<style>や<script>がなければidを削除する。
            // idにアンカーが貼られていたら削除せずにid名を縮小する。
            // id属性は動作の起点となることがあるため削除しない。
            { cleanupIDs: false },
          ],
        }),
        imagemin.optipng(),
        imagemin.gifsicle(),
      ]),
    )
    .pipe(gulp.dest(dest.image))
    .pipe(browserSync.reload({ stream: true }));
}

/**
 * SVGファイルからSVGスプライトを生成します。
 */
function svgSprite() {
  return gulp
    .src(src.svgSprite)
    .pipe(plumber({ errorHandler: notify.onError('Error: <%= error.message %>') }))
    .pipe(
      gulpSvgSprite({
        mode: {
          // SVGファイルをsymbol要素としてまとめる。
          symbol: {
            dest: './',
            // 出力するファイル名。
            sprite: 'sprite.svg',
          },
        },
        shape: {
          transform: [
            {
              svgo: {
                plugins: [
                  // `style`属性を削除する。
                  { removeStyleElement: true },
                  // `fill`属性を削除して、CSSで`fill`の変更ができるようにする。
                  { removeAttrs: { attrs: 'fill' } },
                ],
              },
            },
          ],
        },
        svg: {
          // xml宣言を出力する。
          xmlDeclaration: false,
          // DOCTYPE宣言を出力する。
          doctypeDeclaration: false,
        },
      }),
    )
    .pipe(gulp.dest(dest.svgSprite))
    .pipe(browserSync.reload({ stream: true }));
}

/**
 * スタイルガイドを生成します。
 * aigisは開発が止まっているので、別のスタイルガイドジェネレーターを検討してください。
 */
function styleguide() {
  return gulp.src('./aigis/aigis_config.yml').pipe(aigis());
}

/**
 * Gulpの処理を通さないディレクトリです。
 * 公開用のディレクトリにコピーします。
 */
function copy() {
  return gulp.src(src.copy).pipe(gulp.dest(dest.root));
}

/**
 * ローカルサーバーを起動します。
 */
function serve(done) {
  browserSync({
    server: {
      // SSIを使用します。
      // middleware: [
      //   browserSyncSsi({
      //     baseDir: dest.root,
      //     ext: '.html',
      //   }),
      // ],
      baseDir: dest.root,
    },
    // 画面を共有するときにスクロールやクリックなどをミラーリングしたくない場合はfalseにします。
    ghostMode: false,
    // ローカルIPアドレスでサーバーを立ち上げます。
    open: 'external',
    // サーバー起動時に表示するページを指定します。
    startPath: '/styleguide/',
    // falseに指定すると、サーバー起動時にポップアップを表示させません。
    notify: false,
  });
  done();
}

/**
 * 公開用のディレクトリを削除します。
 */
function clean() {
  return del(dest.cleanDest);
}

/**
 * publicなgulpタスクです。
 * `gulp html`のように実行できます。
 */
exports.html = html;
exports.htmlValidate = htmlValidate;
exports.ssi = ssi;
exports.stylelint = stylelint;
exports.css = css;
exports.js = js;
exports.image = image;
exports.svgSprite = svgSprite;
exports.styleguide = styleguide;
exports.copy = copy;
exports.serve = serve;
exports.clean = clean;

/**
 * ファイルを監視します。
 */
function watch() {
  gulp.watch(src.htmlWatch, html);
  gulp.watch(src.imageWatch, image);
  gulp.watch(src.ssi, ssi);
  gulp.watch(src.css, css);
  gulp.watch(src.jsWatch, js);
  gulp.watch(src.svgSprite, svgSprite);
  gulp.watch(src.styleguideWatch, styleguide);
  gulp.watch(src.copy, copy);
}

/**
 * 開発タスクをすべて実行します。
 */
exports.build = gulp.series(
  gulp.parallel(clean),
  html,
  ssi,
  css,
  styleguide,
  js,
  image,
  svgSprite,
  copy,
);

/**
 * 開発タスクをすべて実行します。
 * ローカルサーバーを起動し、リアルタイムに更新を反映させます。
 */
exports.default = gulp.series(
  gulp.parallel(clean),
  html,
  ssi,
  css,
  styleguide,
  js,
  image,
  svgSprite,
  copy,
  gulp.parallel(serve, watch),
);
<|endoftext|>


<commit_before>'use strict';

let gulp = require( 'gulp' ),
sass = require( 'gulp-sass' ),
autoprefixer = require( 'gulp-autoprefixer' ),
nano = require( 'gulp-cssnano' ),
uglify = require( 'gulp-uglify' ),
imagemin = require( 'gulp-imagemin' ),
rename = require( 'gulp-rename' ),
concat = require( 'gulp-concat' ),
sourcemaps = require( 'gulp-sourcemaps' ),
del = require( 'del' ),
notify = require( 'gulp-notify' ),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
eslint = require('gulp-eslint'),
babel = require('gulp-babel');
browserSync = require( 'browser-sync' ).create();

require( 'es6-promise' ).polyfill();

gulp.task( 'styles', function() {

	// List al your SASS files HERE
	let scss_files = [
	'assets/styles/main.scss'
	];

	gulp.src( scss_files )
	.pipe( sourcemaps.init() )
	.pipe( sass() ).on( 'error', notify.onError( function ( error ) {
		return "SASS Error: " + error.message;
	}))
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( sourcemaps.write() )
	.pipe( gulp.dest( 'dist/styles' ) )
	.pipe( browserSync.stream() )
	.pipe( notify( 'SCSS files compiled' ) );			// Output to notification
});

gulp.task( 'styles-min', function() {
	let scss_files = [
	'assets/styles/main.scss'
	];

	gulp.src( scss_files )
	.pipe( sass( {errLogToConsole: true} ) )
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( rename( {suffix: '.min'} ) )
	.pipe( nano( {
		discardComments: {
			removeAll: true
		}
	} ) )
	.pipe( gulp.dest( 'dist/styles' ) )
	.pipe( notify( 'SCSS files compiled and minified' ) );			// Output to notification
});

gulp.task( 'rtl-styles', function() {

	// List al your SASS files HERE
	let scss_files = [
	'assets/styles/rtl.scss'
	];

	gulp.src( scss_files )
	.pipe( sourcemaps.init() )
	.pipe( sass() ).on( 'error', notify.onError( function ( error ) {
		// return "SASS Error: " + error.message;
	}))
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( sourcemaps.write() )
	.pipe( gulp.dest( 'dist/styles' ) )
	.pipe( browserSync.stream() )
	.pipe( notify( 'RTL styles compiled' ) );
});

gulp.task( 'rtl-styles-min', function() {

	let scss_files = [
	'assets/styles/rtl.scss'
	];

	gulp.src( scss_files )
	.pipe( sass( {errLogToConsole: true} ) )
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( rename( {
		suffix: '.min'
	} ) )
	.pipe( nano( {
		discardComments: {
			removeAll: true
		}
	} ) )
	.pipe( gulp.dest('dist/styles') )
	.pipe( browserSync.stream() )
	.pipe( notify( 'RTL styles compiled and minified' ) );
});

gulp.task( 'custom-scripts', function() {

	return gulp.src( 'assets/scripts/**/*.js' )

	.pipe( jshint() )
	.pipe( jshint.reporter( 'jshint-stylish' ) )

	.pipe( eslint( {
		fix: true
	} ) )
	.pipe( eslint.format() )
	.pipe(babel({
		presets: ['es2015']
	}))
	.pipe( notify( 'Javascripts linted' ) );			// Output to notification
});

// List all your JS files HERE
let js_files = [
'bower_components/jquery/dist/jquery.js',
'bower_components/jquery.cookie/jquery.cookie.js',
'bower_components/jquery-placeholder/jquery-placeholder.js',
'bower_components/foundation-sites/dist/js/foundation.js',
'assets/scripts/**/*.js'
];

gulp.task( 'scripts', function() {

	return gulp.src( js_files )

	.pipe( sourcemaps.init() )
	.pipe( concat( 'main.js' ) )
	.pipe( sourcemaps.write() )
	.pipe( gulp.dest( 'dist/scripts' ) )
	.pipe( browserSync.stream() )
	.pipe( notify( 'Javascripts compiled' ) );			// Output to notification
});

gulp.task( 'scripts-min', function() {
	return gulp.src( js_files )
	.pipe( concat( 'main.min.js' ) )
	.pipe(babel({
		presets: ['es2015']
	}))
	.pipe( uglify() ).on( "error", notify.onError( function ( error ) {
		let filename = error.fileName.replace(/^.*[\\\/]/, '')
		return "JavaScript error:\n" + filename + "\nLine " +  error.lineNumber;
	}))
	.pipe( gulp.dest( 'dist/scripts' ) )
	.pipe( notify( 'Javascripts compiled and minified' ) );			// Output to notification
});

let php_files = [
'{lib,directives}/**/*.php',
'*.php'
];

gulp.task( 'php', function() {
	return gulp.src( php_files )
	.pipe( browserSync.stream() );
});

let img_files = [
'assets/images/**/*'
];

gulp.task( 'images', function() {
	return gulp.src( img_files )
	.pipe( gulp.dest( 'dist/images' ) )
	.pipe( browserSync.stream() );
});

gulp.task( 'images-min', function() {

	return gulp.src( img_files )
	.pipe( imagemin( {
		optimizationLevel: 3,
		progressive: true,
		interlaced: true
	} ) )
	.pipe( gulp.dest( 'dist/images' ) );
});

let font_files = [
'bower_components/font-awesome/fonts/*',
'assets/fonts/**/*'
];

gulp.task( 'fonts', function() {

	return gulp.src( font_files )
	.pipe( gulp.dest( 'dist/fonts' ) )
	.pipe( browserSync.stream() );
});

gulp.task( 'fonts-min', function() {

	return gulp.src( font_files )
	.pipe( gulp.dest( 'dist/fonts' ) );
});

gulp.task( 'clean', function( cb ) {
	return del( ['dist/styles', 'dist/scripts', 'dist/images', 'dist/fonts'], cb )
});

gulp.task( 'default', ['clean'], function() {
	gulp.start( 'rtl-styles', 'styles', 'custom-scripts', 'scripts', 'php', 'images', 'fonts' );
});

gulp.task( 'production', ['clean'], function() {
	gulp.start( 'styles-min', 'rtl-styles-min', 'scripts-min', 'images-min', 'fonts-min' );
});

gulp.task('watch', function() {

	// Run the styles task first time gulp watch is run
	gulp.start( 'styles' );

	browserSync.init({
		files: ['{lib,directives}/**/*.php', '*.php'],
		proxy: 'http://localhost/DIRECTIRY/',
		snippetOptions: {
			whitelist: ['/wp-admin/admin-ajax.php'],
			blacklist: ['/wp-admin/**']
		}
	});
	gulp.watch( ['assets/styles/**/*'], ['rtl-styles' , 'styles'] );
	gulp.watch( ['assets/scripts/**/*'], ['scripts'] );
	gulp.watch( ['assets/scripts/**/*'], ['custom-scripts'] );
	gulp.watch( ['assets/fonts/**/*'], ['fonts'] );
	gulp.watch( ['assets/images/**/*'], ['images'] );
	gulp.watch( ['{lib,directives}/**/*.php', '*.php'], ['php'] );
});
<commit_msg>gulpfile fixed<commit_after>'use strict';

let gulp = require( 'gulp' ),
sass = require( 'gulp-sass' ),
autoprefixer = require( 'gulp-autoprefixer' ),
nano = require( 'gulp-cssnano' ),
uglify = require( 'gulp-uglify' ),
imagemin = require( 'gulp-imagemin' ),
rename = require( 'gulp-rename' ),
concat = require( 'gulp-concat' ),
sourcemaps = require( 'gulp-sourcemaps' ),
del = require( 'del' ),
notify = require( 'gulp-notify' ),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
eslint = require('gulp-eslint'),
babel = require('gulp-babel'),
browserSync = require( 'browser-sync' ).create();

require( 'es6-promise' ).polyfill();

gulp.task( 'styles', function() {

	// List al your SASS files HERE
	let scss_files = [
	'assets/styles/main.scss'
	];

	gulp.src( scss_files )
	.pipe( sourcemaps.init() )
	.pipe( sass() ).on( 'error', notify.onError( function ( error ) {
		return "SASS Error: " + error.message;
	}))
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( sourcemaps.write() )
	.pipe( gulp.dest( 'dist/styles' ) )
	.pipe( browserSync.stream() )
	.pipe( notify( 'SCSS files compiled' ) );			// Output to notification
});

gulp.task( 'styles-min', function() {
	let scss_files = [
	'assets/styles/main.scss'
	];

	gulp.src( scss_files )
	.pipe( sass( {errLogToConsole: true} ) )
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( rename( {suffix: '.min'} ) )
	.pipe( nano( {
		discardComments: {
			removeAll: true
		}
	} ) )
	.pipe( gulp.dest( 'dist/styles' ) )
	.pipe( notify( 'SCSS files compiled and minified' ) );			// Output to notification
});

gulp.task( 'rtl-styles', function() {

	// List al your SASS files HERE
	let scss_files = [
	'assets/styles/rtl.scss'
	];

	gulp.src( scss_files )
	.pipe( sourcemaps.init() )
	.pipe( sass() ).on( 'error', notify.onError( function ( error ) {
		// return "SASS Error: " + error.message;
	}))
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( sourcemaps.write() )
	.pipe( gulp.dest( 'dist/styles' ) )
	.pipe( browserSync.stream() )
	.pipe( notify( 'RTL styles compiled' ) );
});

gulp.task( 'rtl-styles-min', function() {

	let scss_files = [
	'assets/styles/rtl.scss'
	];

	gulp.src( scss_files )
	.pipe( sass( {errLogToConsole: true} ) )
	.pipe( autoprefixer( {
		browsers: [
		'last 2 versions',
		'android 4',
		'opera 12'
		]
	} ) )
	.pipe( rename( {
		suffix: '.min'
	} ) )
	.pipe( nano( {
		discardComments: {
			removeAll: true
		}
	} ) )
	.pipe( gulp.dest('dist/styles') )
	.pipe( browserSync.stream() )
	.pipe( notify( 'RTL styles compiled and minified' ) );
});

gulp.task( 'custom-scripts', function() {

	return gulp.src( 'assets/scripts/**/*.js' )

	.pipe( jshint() )
	.pipe( jshint.reporter( 'jshint-stylish' ) )

	.pipe( eslint( {
		fix: true
	} ) )
	.pipe( eslint.format() )
	.pipe(babel({
		presets: ['es2015']
	}))
	.pipe( notify( 'Javascripts linted' ) );			// Output to notification
});

// List all your JS files HERE
let js_files = [
'bower_components/jquery/dist/jquery.js',
'bower_components/jquery.cookie/jquery.cookie.js',
'bower_components/jquery-placeholder/jquery-placeholder.js',
'bower_components/foundation-sites/dist/js/foundation.js',
'assets/scripts/**/*.js'
];

gulp.task( 'scripts', function() {

	return gulp.src( js_files )

	.pipe( sourcemaps.init() )
	.pipe( concat( 'main.js' ) )
	.pipe( sourcemaps.write() )
	.pipe( gulp.dest( 'dist/scripts' ) )
	.pipe( browserSync.stream() )
	.pipe( notify( 'Javascripts compiled' ) );			// Output to notification
});

gulp.task( 'scripts-min', function() {
	return gulp.src( js_files )
	.pipe( concat( 'main.min.js' ) )
	.pipe(babel({
		presets: ['es2015']
	}))
	.pipe( uglify() ).on( "error", notify.onError( function ( error ) {
		let filename = error.fileName.replace(/^.*[\\\/]/, '')
		return "JavaScript error:\n" + filename + "\nLine " +  error.lineNumber;
	}))
	.pipe( gulp.dest( 'dist/scripts' ) )
	.pipe( notify( 'Javascripts compiled and minified' ) );			// Output to notification
});

let php_files = [
'{lib,directives}/**/*.php',
'*.php'
];

gulp.task( 'php', function() {
	return gulp.src( php_files )
	.pipe( browserSync.stream() );
});

let img_files = [
'assets/images/**/*'
];

gulp.task( 'images', function() {
	return gulp.src( img_files )
	.pipe( gulp.dest( 'dist/images' ) )
	.pipe( browserSync.stream() );
});

gulp.task( 'images-min', function() {

	return gulp.src( img_files )
	.pipe( imagemin( {
		optimizationLevel: 3,
		progressive: true,
		interlaced: true
	} ) )
	.pipe( gulp.dest( 'dist/images' ) );
});

let font_files = [
'bower_components/font-awesome/fonts/*',
'assets/fonts/**/*'
];

gulp.task( 'fonts', function() {

	return gulp.src( font_files )
	.pipe( gulp.dest( 'dist/fonts' ) )
	.pipe( browserSync.stream() );
});

gulp.task( 'fonts-min', function() {

	return gulp.src( font_files )
	.pipe( gulp.dest( 'dist/fonts' ) );
});

gulp.task( 'clean', function( cb ) {
	return del( ['dist/styles', 'dist/scripts', 'dist/images', 'dist/fonts'], cb )
});

gulp.task( 'default', ['clean'], function() {
	gulp.start( 'rtl-styles', 'styles', 'custom-scripts', 'scripts', 'php', 'images', 'fonts' );
});

gulp.task( 'production', ['clean'], function() {
	gulp.start( 'styles-min', 'rtl-styles-min', 'scripts-min', 'images-min', 'fonts-min' );
});

gulp.task('watch', function() {

	// Run the styles task first time gulp watch is run
	gulp.start( 'styles' );

	browserSync.init({
		files: ['{lib,directives}/**/*.php', '*.php'],
		proxy: 'http://localhost/DIRECTIRY/',
		snippetOptions: {
			whitelist: ['/wp-admin/admin-ajax.php'],
			blacklist: ['/wp-admin/**']
		}
	});
	gulp.watch( ['assets/styles/**/*'], ['rtl-styles' , 'styles'] );
	gulp.watch( ['assets/scripts/**/*'], ['scripts'] );
	gulp.watch( ['assets/scripts/**/*'], ['custom-scripts'] );
	gulp.watch( ['assets/fonts/**/*'], ['fonts'] );
	gulp.watch( ['assets/images/**/*'], ['images'] );
	gulp.watch( ['{lib,directives}/**/*.php', '*.php'], ['php'] );
});
<|endoftext|>


<commit_before>/* eslint-env node */
/* eslint strict: [2, "global"] */
'use strict';

var concat = require('gulp-concat');
var debug = require('gulp-debug');
var del = require('del');
var gulp = require('gulp');
var gulpIf = require('gulp-if');
var lazypipe = require('lazypipe');
var minifyCSS = require('gulp-minify-css');
var minimist = require('minimist');
var path = require('path');
var rename = require('gulp-rename');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var targetHTML = require('gulp-targethtml');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var useref = require('gulp-useref');

var argv = minimist(process.argv);

var apps = [
  'classmentors',
  'singpath'
];

var config = {
  src: 'src/',
  watch: ['src/**/*.html', 'src/**/*.css', 'src/**/*.js', '!src/vendor/**/*'],
  apps: apps,
  pages: 'src/*.html',
  appFiles: apps.map(function(app) {
    return 'src/' + app + '/**/*';
  }),
  vendorFiles: 'src/vendor/**/*',
  assetsFiles: 'src/assets/**/*',
  sharedFiles: 'src/shared/**/*',
  build: {
    concat: './build',
    debug: './build-debug',
    dev: './build-dev',
    dist: './dist',
    e2e: './build-e2e'
  },
  ace: {
    assets: [
      'src/vendor/ace-builds/src-noconflict/mode-html.js',
      'src/vendor/ace-builds/src-noconflict/mode-javascript.js',
      'src/vendor/ace-builds/src-noconflict/mode-python.js',
      'src/vendor/ace-builds/src-noconflict/theme-twilight.js',
      'src/vendor/ace-builds/src-noconflict/worker-html.js',
      'src/vendor/ace-builds/src-noconflict/worker-javascript.js',
      'src/vendor/ace-builds/src-noconflict/worker-html.js'
    ],
    base: 'src/vendor/ace-builds/src-noconflict'
  },
  // only used for build:concat and dist
  dest: argv.dest ? path.resolve(argv.dest) : null,
  noduleNames: {
    singpath: 'spf',
    classmentors: 'clm'
  }
};

/**
 * Simply copy build and process index.html for targets
 *
 */
function copyBuid(target, dest) {
  dest = dest || config.build[target];

  return gulp.src([config.pages], {
      base: config.src
    })
    .pipe(targetHTML(target))
    .pipe(gulp.src([config.vendorFiles, config.assetsFiles, config.sharedFiles].concat(config.appFiles), {
      base: config.src,
      passthrough: true
    }))
    .pipe(gulp.dest(dest));
}

var compilers = config.apps.reduce(function(prev, appName) {
  prev[appName] = lazypipe()
    .pipe(gulp.src, [
      config.src + appName + '/**/*.html',
      config.src + 'shared/**/*.html',
      config.src + appName + '/**/*.svg',
      config.src + 'shared/**/*.svg'
    ], {
      base: config.src,
      passthrough: true
    })
    .pipe(function() {
      return gulpIf(/.+\.(html|svg)/, templateCache({
        module: config.noduleNames[appName],
        base: path.resolve(config.src)
      }));
    })
    .pipe(concat, 'app.js');
  return prev;
}, {});

/**
 * Stream that build and dist tasks will share
 *
 */
function concatBuild(appName) {
  var assets = useref.assets({searchPath: config.src});

  return gulp.src([config.src + appName + '.html'], {
      base: config.src
    })
    .pipe(rename('index.html'))
    // remove some of the html block
    .pipe(targetHTML('live'))
    // Concat scrips (css and js).
    .pipe(assets)
    .pipe(assets.restore())
    .pipe(useref())
    // Add compiled html templates and svg icons into app.js
    .pipe(gulpIf(/app\.js/, compilers[appName]()))
    // Add ace assets
    .pipe(gulp.src(config.ace.assets, {
      base: config.ace.base,
      passthrough: true
    }));
}

/**
 * Stream shared by the 3 app concat build tasks.
 *
 */
function buildApp(appName, dest) {
  dest = dest || config.build.concat;

  // Append a hash to most assets file
  return concatBuild(appName)
    .pipe(gulpIf(/(app|vendor)\.(js|css)/, rev()))
    .pipe(revReplace())
    .pipe(gulp.dest(dest + '/' + appName));
}

/**
 * Stream shared by the 3 app dist tasks
 *
 */
function buildAppDist(appName, dest) {
  dest = dest || config.build.dist;

  // Append a hash to all assets file
  return concatBuild(appName)
    .pipe(gulpIf('*.js', uglify()))
    .pipe(gulpIf('*.css', minifyCSS()))
    .pipe(gulpIf(/(app|vendor)\.(js|css)/, rev()))
    .pipe(revReplace())
    .pipe(gulp.dest(dest + '/' + appName));
}

/**
 * Delete all build reportories (build/, dist/, debug/ and e2e/)
 *
 */
function clean(done) {
  var folders = Object.keys(config.build).map(function(k) {
    return config.build[k];
  });

  if (config.dest) {
    folders.push(config.dest);
  }

  del(folders, {
    force: true
  }, done);

}
gulp.task('clean', clean);

/**
 * Copy src/ to build-dev/ and tweak mocking.
 *
 */
function buildDev() {
  return copyBuid('dev', config.build.dev);
}
gulp.task('build:dev', gulp.series(clean, buildDev));

/**
 * Copy src/ to debug/ and remove any mocking.
 *
 */
function buildDebug() {
  return copyBuid('live', config.build.debug);
}
gulp.task('build:debug', gulp.series(clean, buildDebug));

/**
 * Copy src/ to e2e/ and remove the mocked spf module. But unlike debug,
 * it keeps the loading angular-mocks and and spf ficture data. It's up
 * to each e2e scenario to mock th http response.
 *
 */
function buildE2E() {
  return copyBuid('e2e');
}
gulp.task('build:e2e', gulp.series(clean, buildE2E));

/**
 * Build the apps into build/<app name> by removing any mocking and by concataning
 * assets for each app.
 */
var buildConcat = gulp.parallel(config.apps.map(function(appName) {
  var taskName = 'build/concat: ' + appName;

  gulp.task(taskName, function() {
    return buildApp(appName, config.dest);
  });

  return taskName;
}));
gulp.task('build:concat', gulp.series(clean, buildConcat));

/**
 * Build all app type.
 */
gulp.task(
  'build',
  gulp.series(
    clean,
    gulp.parallel(buildDev, buildDebug, buildE2E, buildConcat)
  )
);

/**
 * Watch tasks
 */
gulp.task('watch', gulp.parallel('build', function buildWather() {
  gulp.watch(config.watch, gulp.task('build'));
}));

['dev', 'debug', 'e2e', 'concat'].forEach(function(buildType) {
  var taskName = 'watch:' + buildType;
  var buildTaskName = 'build:' + buildType;

  gulp.task(taskName, gulp.parallel(buildTaskName, function SomeBuildWatcher() {
    gulp.watch(config.watch, gulp.task(buildTaskName));
  }));
});

/**
 * Like build but minify css and js files too.
 *
 */
var dist = gulp.parallel(config.apps.map(function(appName) {
  var taskName = 'build/concat: ' + appName;

  gulp.task(taskName, function() {
    return buildAppDist(appName, config.dest);
  });

  return taskName;
}));
gulp.task('dist', gulp.series(clean, dist));

/**
 * Default task
 */
gulp.task('default', gulp.parallel('build:concat'));
<commit_msg>Fix gulpfile<commit_after>/* eslint-env node */
/* eslint strict: [2, "global"] */
'use strict';

var concat = require('gulp-concat');
var debug = require('gulp-debug');
var del = require('del');
var gulp = require('gulp');
var gulpIf = require('gulp-if');
var lazypipe = require('lazypipe');
var minifyCSS = require('gulp-minify-css');
var minimist = require('minimist');
var path = require('path');
var rename = require('gulp-rename');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var targetHTML = require('gulp-targethtml');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var useref = require('gulp-useref');

var argv = minimist(process.argv);

var apps = [
  'classmentors',
  'singpath'
];

var config = {
  src: 'src/',
  watch: ['src/**/*.html', 'src/**/*.css', 'src/**/*.js', '!src/vendor/**/*'],
  apps: apps,
  pages: 'src/*.html',
  appFiles: apps.map(function(app) {
    return 'src/' + app + '/**/*';
  }),
  vendorFiles: 'src/vendor/**/*',
  assetsFiles: 'src/assets/**/*',
  sharedFiles: 'src/shared/**/*',
  build: {
    concat: './build',
    debug: './build-debug',
    dev: './build-dev',
    dist: './dist',
    e2e: './build-e2e'
  },
  ace: {
    assets: [
      'src/vendor/ace-builds/mode-html.js',
      'src/vendor/ace-builds/mode-javascript.js',
      'src/vendor/ace-builds/mode-python.js',
      'src/vendor/ace-builds/theme-twilight.js',
      'src/vendor/ace-builds/worker-html.js',
      'src/vendor/ace-builds/worker-javascript.js',
      'src/vendor/ace-builds/worker-html.js'
    ],
    base: 'src/vendor/ace-builds/src-noconflict'
  },
  // only used for build:concat and dist
  dest: argv.dest ? path.resolve(argv.dest) : null,
  noduleNames: {
    singpath: 'spf',
    classmentors: 'clm'
  }
};

/**
 * Simply copy build and process index.html for targets
 *
 */
function copyBuid(target, dest) {
  dest = dest || config.build[target];

  return gulp.src([config.pages], {
      base: config.src
    })
    .pipe(targetHTML(target))
    .pipe(gulp.src([config.vendorFiles, config.assetsFiles, config.sharedFiles].concat(config.appFiles), {
      base: config.src,
      passthrough: true
    }))
    .pipe(gulp.dest(dest));
}

var compilers = config.apps.reduce(function(prev, appName) {
  prev[appName] = lazypipe()
    .pipe(gulp.src, [
      config.src + appName + '/**/*.html',
      config.src + 'shared/**/*.html',
      config.src + appName + '/**/*.svg',
      config.src + 'shared/**/*.svg'
    ], {
      base: config.src,
      passthrough: true
    })
    .pipe(function() {
      return gulpIf(/.+\.(html|svg)/, templateCache({
        module: config.noduleNames[appName],
        base: path.resolve(config.src)
      }));
    })
    .pipe(concat, 'app.js');
  return prev;
}, {});

/**
 * Stream that build and dist tasks will share
 *
 */
function concatBuild(appName) {
  var assets = useref.assets({searchPath: config.src});

  return gulp.src([config.src + appName + '.html'], {
      base: config.src
    })
    .pipe(rename('index.html'))
    // remove some of the html block
    .pipe(targetHTML('live'))
    // Concat scrips (css and js).
    .pipe(assets)
    .pipe(assets.restore())
    .pipe(useref())
    // Add compiled html templates and svg icons into app.js
    .pipe(gulpIf(/app\.js/, compilers[appName]()))
    // Add ace assets
    .pipe(gulp.src(config.ace.assets, {
      base: config.ace.base,
      passthrough: true
    }));
}

/**
 * Stream shared by the 3 app concat build tasks.
 *
 */
function buildApp(appName, dest) {
  dest = dest || config.build.concat;

  // Append a hash to most assets file
  return concatBuild(appName)
    .pipe(gulpIf(/(app|vendor)\.(js|css)/, rev()))
    .pipe(revReplace())
    .pipe(gulp.dest(dest + '/' + appName));
}

/**
 * Stream shared by the 3 app dist tasks
 *
 */
function buildAppDist(appName, dest) {
  dest = dest || config.build.dist;

  // Append a hash to all assets file
  return concatBuild(appName)
    .pipe(gulpIf('*.js', uglify()))
    .pipe(gulpIf('*.css', minifyCSS()))
    .pipe(gulpIf(/(app|vendor)\.(js|css)/, rev()))
    .pipe(revReplace())
    .pipe(gulp.dest(dest + '/' + appName));
}

/**
 * Delete all build reportories (build/, dist/, debug/ and e2e/)
 *
 */
function clean(done) {
  var folders = Object.keys(config.build).map(function(k) {
    return config.build[k];
  });

  if (config.dest) {
    folders.push(config.dest);
  }

  del(folders, {
    force: true
  }, done);

}
gulp.task('clean', clean);

/**
 * Copy src/ to build-dev/ and tweak mocking.
 *
 */
function buildDev() {
  return copyBuid('dev', config.build.dev);
}
gulp.task('build:dev', gulp.series(clean, buildDev));

/**
 * Copy src/ to debug/ and remove any mocking.
 *
 */
function buildDebug() {
  return copyBuid('live', config.build.debug);
}
gulp.task('build:debug', gulp.series(clean, buildDebug));

/**
 * Copy src/ to e2e/ and remove the mocked spf module. But unlike debug,
 * it keeps the loading angular-mocks and and spf ficture data. It's up
 * to each e2e scenario to mock th http response.
 *
 */
function buildE2E() {
  return copyBuid('e2e');
}
gulp.task('build:e2e', gulp.series(clean, buildE2E));

/**
 * Build the apps into build/<app name> by removing any mocking and by concataning
 * assets for each app.
 */
var buildConcat = gulp.parallel(config.apps.map(function(appName) {
  var taskName = 'build/concat: ' + appName;

  gulp.task(taskName, function() {
    return buildApp(appName, config.dest);
  });

  return taskName;
}));
gulp.task('build:concat', gulp.series(clean, buildConcat));

/**
 * Build all app type.
 */
gulp.task(
  'build',
  gulp.series(
    clean,
    gulp.parallel(buildDev, buildDebug, buildE2E, buildConcat)
  )
);

/**
 * Watch tasks
 */
gulp.task('watch', gulp.parallel('build', function buildWather() {
  gulp.watch(config.watch, gulp.task('build'));
}));

['dev', 'debug', 'e2e', 'concat'].forEach(function(buildType) {
  var taskName = 'watch:' + buildType;
  var buildTaskName = 'build:' + buildType;

  gulp.task(taskName, gulp.parallel(buildTaskName, function SomeBuildWatcher() {
    gulp.watch(config.watch, gulp.task(buildTaskName));
  }));
});

/**
 * Like build but minify css and js files too.
 *
 */
var dist = gulp.parallel(config.apps.map(function(appName) {
  var taskName = 'build/concat: ' + appName;

  gulp.task(taskName, function() {
    return buildAppDist(appName, config.dest);
  });

  return taskName;
}));
gulp.task('dist', gulp.series(clean, dist));

/**
 * Default task
 */
gulp.task('default', gulp.parallel('build:concat'));
<|endoftext|>


<commit_before>const gulp = require('gulp');
const eslint = require('gulp-eslint');
const webpack = require('webpack-stream');
const exec = require('child_process').exec;
const scripts = ['*.js', 'app/*.js', 'test/*.js'];
const protractor = require('gulp-protractor').protractor;

gulp.task('lint', () => {
  return gulp.src(scripts)
  .pipe(eslint())
  .pipe(eslint.format());
});

gulp.task('webpack', () => {
  return gulp.src('app/js/*.js')
  .pipe(webpack({
    output: {
      filename: 'bundle.js'
    }
  }))
  .pipe(gulp.dest('./build'));
});

gulp.task('staticHTML', () => {
  return gulp.src('app/**/*.html')
  .pipe(gulp.dest('./build'));
});

gulp.task('css', () => {
  return gulp.src('app/**/*.css')
  .pipe(gulp.dest('./build'));
});

gulp.task('server', (done) => {
  exec('node server.js', (err, stdout, stderr) => { //  eslint-disable-line handle-callback-err
    process.stdout.write(stdout + '\n');
    process.stderr.write(stderr + '\n');
    done();
  });
});

gulp.task('selenium', (done) => {
  exec('webdriver-manager start', (err, stdout, stderr) => { //  eslint-disable-line handle-callback-err
    process.stdout.write(stdout + '\n');
    process.stderr.write(stderr + '\n');
    done();
  });
});

gulp.task('protractor', () => {
  return gulp.src('test/integration/*spec.js')
  .pipe(protractor({
    configFile: 'test/integration/config.js',
    args: ['--baseurl', 'http://127.0.0.1:8000']
  }));
});

gulp.task('test', ['build', 'server', 'selenium', 'protractor']);
gulp.task('build', ['lint', 'webpack', 'staticHTML', 'css']);
gulp.task('default', ['lint']);
<commit_msg>removed eslint-disable-line<commit_after>const gulp = require('gulp');
const eslint = require('gulp-eslint');
const webpack = require('webpack-stream');
const exec = require('child_process').exec;
const scripts = ['*.js', 'app/*.js', 'test/*.js'];
const protractor = require('gulp-protractor').protractor;

gulp.task('lint', () => {
  return gulp.src(scripts)
  .pipe(eslint())
  .pipe(eslint.format());
});

gulp.task('webpack', () => {
  return gulp.src('app/js/*.js')
  .pipe(webpack({
    output: {
      filename: 'bundle.js'
    }
  }))
  .pipe(gulp.dest('./build'));
});

gulp.task('staticHTML', () => {
  return gulp.src('app/**/*.html')
  .pipe(gulp.dest('./build'));
});

gulp.task('css', () => {
  return gulp.src('app/**/*.css')
  .pipe(gulp.dest('./build'));
});

gulp.task('server', (done) => {
  exec('node server.js', (err, stdout, stderr) => {
    if (err) throw err;
    process.stdout.write(stdout + '\n');
    process.stderr.write(stderr + '\n');
    done();
  });
});

gulp.task('selenium', (done) => {
  exec('webdriver-manager start', (err, stdout, stderr) => {
    if (err) throw err;
    process.stdout.write(stdout + '\n');
    process.stderr.write(stderr + '\n');
    done();
  });
});

gulp.task('protractor', () => {
  return gulp.src('test/integration/*spec.js')
  .pipe(protractor({
    configFile: 'test/integration/config.js',
    args: ['--baseurl', 'http://127.0.0.1:8000']
  }));
});

gulp.task('test', ['build', 'server', 'selenium', 'protractor']);
gulp.task('build', ['lint', 'webpack', 'staticHTML', 'css']);
gulp.task('default', ['lint']);
<|endoftext|>