Blame view

bower_components/d3-scatterplot/gulpfile.js 2.33 KB
50380d5a   mwasiluk   d3 scatterplot-da...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  var gulp = require('gulp');
  var del = require('del');
  var merge = require('merge-stream');
  var plugins = require('gulp-load-plugins')();
  var browserSync = require('browser-sync').create();
  
  gulp.task('clean', function (cb) {
      return del(['tmp', 'dist'], cb);
  });
  
  gulp.task('build-css', function () {
      var pretty = gulp.src('./styles/*')
          .pipe(plugins.plumber({ errorHandler: onError }))
          .pipe(plugins.sass())
          .pipe(plugins.minifyCss())
          .pipe(plugins.rename({
              extname: '.min.css'
          }))
          .pipe(gulp.dest('./dist'));
      var ugly = gulp.src('./styles/*')
          .pipe(plugins.plumber({ errorHandler: onError }))
          .pipe(plugins.sass())
          .pipe(plugins.rename({
              extname: '.css'
          }))
          .pipe(gulp.dest('./dist'));
      return merge(pretty, ugly);
  });
  
  gulp.task('build-js', function () {
      var jsFileName = 'd3-scatterplot';
     var pretty = gulp.src('./src/*.js')
          .pipe(plugins.plumber({ errorHandler: onError }))
          .pipe(plugins.concat(jsFileName+'.js'))
          .pipe(gulp.dest('dist'));
  
      var ugly = gulp.src('./src/*.js')
          .pipe(plugins.plumber({ errorHandler: onError }))
          .pipe(plugins.uglify())
          .pipe(plugins.stripDebug())
          .pipe(plugins.concat(jsFileName+'.min.js'))
          .pipe(gulp.dest('dist'));
  
      return merge(pretty, ugly);
  });
  
  gulp.task('build-clean', ['clean'], function () {
      gulp.start('build');
  });
  
  gulp.task('build', ['build-css', 'build-js'], function () {
  
  });
  
  gulp.task('watch', function() {
      return gulp.watch(['./src/**/*.html', './styles/*.*css', 'src/**/*.js'], ['default']);
  });
  
  gulp.task('default', ['build-clean'],  function() {
  
  });
  
  gulp.task('default-watch', ['default'], ()=>{ browserSync.reload() });
  gulp.task('serve', ['default'], ()=>{
      browserSync.init({
          server: {
              baseDir: "demo",
              index: "index.html",
              routes: {
                  "/bower_components": "bower_components",
                  "/dist": "dist"
              }
          },
          port: 8089,
          open: 'local',
          browser: "google chrome"
      });
      gulp.watch(['i18n/**/*.json', './src/**/*.html', './styles/*.*css', 'src/**/*.js', 'demo/*.*'], ['default-watch']);
  });
  
  // error function for plumber
  var onError = function (err) {
      console.log(err);
      this.emit('end');
  };