forked from coderstats/coderstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
62 lines (53 loc) · 1.71 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
var gulp = require('gulp'),
babel = require('gulp-babel'),
minify = require('gulp-babel-minify'),
cleanCSS = require('gulp-clean-css'),
concat = require('gulp-concat'),
spawn = require('child_process').spawn,
sass = require('gulp-sass');
var do_minify = true;
var paths = {
babel: 'src/js/*.js',
compiled: 'static/compiled',
scss: 'src/scss/*.scss',
scss_coder: 'src/scss/coder.scss',
scss_main: 'src/scss/style.scss'
};
// Compile babel scripts
gulp.task('babel', function() {
var ret = gulp.src(paths.babel).pipe(babel());
if (do_minify)
ret = ret.pipe(minify())
return ret.pipe(gulp.dest(paths.compiled));
});
// Run dev server
gulp.task('serve', function() {
var log = function (data) { console.log(data.toString()) };
lserve = spawn('logya', ['serve']);
lserve.stdout.on('data', log);
lserve.stderr.on('data', log);
});
// Compile and copy scss styles
gulp.task('scss', function () {
gulp.src(paths.scss_coder)
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS())
.pipe(concat('coder.css'))
.pipe(gulp.dest(paths.compiled));
return gulp.src(paths.scss_main)
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS())
.pipe(concat('style.css'))
.pipe(gulp.dest(paths.compiled));
});
// Rerun task when a file changes
gulp.task('watch', function() {
// don't minify while working on code
do_minify = false;
gulp.watch(paths.scss, ['scss']);
gulp.watch(paths.babel, ['babel']);
});
// Build the JavaScript and CSS files
gulp.task('dist', ['babel', 'scss']);
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['dist', 'watch', 'serve']);