This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGulpfile.js
77 lines (68 loc) · 2.3 KB
/
Gulpfile.js
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
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var del = require('del');
var paths = {
scripts: ['src/**/*.coffee'],
styles: ['src/**/*.scss'],
demoResources: ['demo/**/*.*', 'dist/**/*.*', '!demo/src/**'],
demoScripts: ['demo/src/**/*.coffee'],
dist: 'dist',
demoOut: 'build'
};
gulp.task('clean', function(cb) {
del([paths.dist, paths.demoOut], cb);
});
// Create the distributable artifacts of the plugin.
gulp.task('dist:main', function () {
return gulp.src(paths.scripts)
.pipe(coffee())
.pipe(concat('d3-flame-graph.js'))
.pipe(gulp.dest(paths.dist))
});
gulp.task('dist:min', function () {
return gulp.src(paths.scripts)
.pipe(coffee())
.pipe(uglify())
.pipe(concat('d3-flame-graph.min.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('dist:styles', function () {
return gulp.src(paths.styles)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(paths.dist))
});
gulp.task('dist', ['dist:min', 'dist:main', 'dist:styles']);
// building the demo page
gulp.task('demo-scripts', ['dist'], function() {
// Minify and copy all JavaScript (except vendor scripts)
// with sourcemaps all the way down
return gulp.src(paths.demoScripts)
.pipe(sourcemaps.init())
.pipe(coffee())
.pipe(concat('demo.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.demoOut));
});
gulp.task('demo-copy', ['demo-scripts'], function() {
return gulp.src(paths.demoResources)
.pipe(gulp.dest(paths.demoOut));
});
// Rerun the task when a file changes
gulp.task('demo-watch', ['demo-copy'], function() {
gulp.watch(paths.scripts, ['demo-copy']);
gulp.watch(paths.styles, ['demo-copy']);
gulp.watch(paths.demoResources, ['demo-copy']);
gulp.watch(paths.demoScripts, ['demo-copy']);
});
gulp.task('serve', ['demo-watch'], function() {
browserSync({ server: { baseDir: paths.demoOut } });
gulp.watch(['*.html', '*.css', '*.js'], { cwd: paths.demoOut }, reload);
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['serve']);