-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
60 lines (47 loc) · 1.57 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
// Requirements
// ============================================================================
var gulp = require('gulp')
var cssnext = require('gulp-cssnext')
var watch = require('gulp-watch')
var browserify = require('browserify')
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify')
var rename = require('gulp-rename');
// Paths
// ============================================================================
var rootPath = process.cwd() + '/app/app/static/';
var cssPath = rootPath + '/css/';
var jsPath = rootPath + '/js/';
// Gulp Tasks
// ============================================================================
// Concatenate and process stylesheets with CSSNext
gulp.task('css', function() {
gulp.src(cssPath + 'index.css')
.pipe(cssnext())
.pipe(rename('site.css'))
.pipe(gulp.dest(rootPath))
});
// Concatenate and browserify JS sourcefiles.
gulp.task('js', function() {
return browserify(jsPath + 'index.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest(rootPath));
});
gulp.task('minify:js', ['js'], function() {
return browserify(jsPath + 'index.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(rootPath));
});
// Watch for changes and rerun tasks.
gulp.task('watch', function() {
gulp.watch(cssPath + '*.css', ['css']);
gulp.watch(jsPath + '*.js', ['js']);
});
// Register default tasks
gulp.task('develop', ['watch']);
gulp.task('production', ['minify:js']);