text: // generated on 2017-12-07 using generator-chrome-extension 0.7.0
  // altered on 2017-12-07 using fox paws
  import gulp from 'gulp';
  import gulpLoadPlugins from 'gulp-load-plugins';
  import del from 'del';
  import runSequence from 'run-sequence';
  import {stream as wiredep} from 'wiredep';
  
  const $ = gulpLoadPlugins();
  
  gulp.task('extras', () => {
    return gulp.src([
      'app/*.*',
      'app/_locales/**',
      '!app/scripts.babel',
      '!app/*.json',
      '!app/*.html',
    ], {
      base: 'app',
      dot: true
    }).pipe(gulp.dest('dist'));
  });
  
  function lint(files, options) {
    return () => {
      return gulp.src(files)
        .pipe($.eslint(options))
        .pipe($.eslint.format());
    };
  }
  
  gulp.task('lint', lint('app/scripts.babel/**/*.js', {
    env: {
      es6: true
    }
  }));
  
  gulp.task('images', () => {
    return gulp.src('app/images/**/*')
      .pipe($.if($.if.isFile, $.cache($.imagemin({
        progressive: true,
        interlaced: true,
        // don't remove IDs from SVGs, they are often used
        // as hooks for embedding and styling
        svgoPlugins: [{cleanupIDs: false}]
      }))
      .on('error', function (err) {
        console.log(err);
        this.end();
      })))
      .pipe(gulp.dest('dist/images'));
  });
  
  gulp.task('html',  () => {
    return gulp.src('app/*.html')
      .pipe($.useref({searchPath: ['.tmp', 'app', '.']}))
      .pipe($.sourcemaps.init())
      .pipe($.if('*.js', $.uglify()))
      .pipe($.if('*.css', $.cleanCss({compatibility: '*'})))
      .pipe($.sourcemaps.write())
      .pipe($.if('*.html', $.htmlmin({
        collapseWhitespace: true,
        minifyCSS: true,
        minifyJS: true,
        removeComments: true
      })))
      .pipe(gulp.dest('dist'));
  });
  
  gulp.task('chromeManifest', () => {
    return gulp.src('app/manifest.json')
      .pipe($.chromeManifest({
        buildnumber: true,
        background: {
          target: 'scripts/background.js',
          exclude: [
            'scripts/chromereload.js'
          ]
        }
    }))
    .pipe($.if('*.css', $.cleanCss({compatibility: '*'})))
    .pipe($.if('*.js', $.sourcemaps.init()))
    .pipe($.if('*.js', $.uglify()))
    .pipe($.if('*.js', $.sourcemaps.write('.')))
    .pipe(gulp.dest('dist'));
  });
  
  gulp.task('babel', () => {
    return gulp.src('app/scripts.babel/**/*.js')
        .pipe($.babel({
          presets: ['es2015']
        }))
        .pipe(gulp.dest('app/scripts'));
  });
  
  gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
  
  gulp.task('watch', ['lint', 'babel'], () => {
    $.livereload.listen();
  
    gulp.watch([
      'app/*.html',
      'app/scripts/**/*.js',
      'app/images/**/*',
      'app/styles/**/*',
      'app/_locales/**/*.json'
    ]).on('change', $.livereload.reload);
  
    gulp.watch('app/scripts.babel/**/*.js', ['lint', 'babel']);
    gulp.watch('bower.json', ['wiredep']);
  });
  
  gulp.task('size', () => {
    return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
  });
  
  gulp.task('copyac', () => {
    gulp.src('./node_modules/adaptivecards/dist/adaptivecards.js')
      .pipe(gulp.dest('app'));
  });
  
  gulp.task('wiredep', () => {
    gulp.src('app/*.html')
      .pipe(wiredep({
        ignorePath: /^(\.\.\/)*\.\./
      }))
      .pipe(gulp.dest('app'));
  });
  
  gulp.task('package', function () {
    var manifest = require('./dist/manifest.json');
    return gulp.src('dist/**')
        .pipe($.zip('AdaptiveCardsChrome-' + manifest.version + '.zip'))
        .pipe(gulp.dest('package'));
  });
  
  gulp.task('build', (cb) => {
    runSequence(
      'copyac', 'lint', 'babel', 'chromeManifest',
      ['html', 'images', 'extras'],
      'size', cb);
  });
  
  gulp.task('default', ['clean'], cb => {
    runSequence('build', cb);
  });
  