-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·77 lines (69 loc) · 1.86 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
'use strict';
// included gulp components
var gulp = require('gulp');
var argv = require('yargs').argv;
var sass = require('gulp-sass');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var browserify = require('gulp-browserify');
var buffer = require('vinyl-buffer');
var uglifycss = require("gulp-uglifycss");
// variables
var config = {
toWatch: {
coffee: [
'./assets/coffee/**/*.coffee'
],
sass: [
'./assets/sass/**/*.sass',
],
mainSass: [
'./assets/sass/main.sass'
]
},
outputFiles: {
coffee: 'main.js',
sass: 'main.css',
},
outputDirs: {
css: './dist/styles',
js: './dist/scripts',
}
};
// converts coffee files into main.js
gulp.task('scripts', function() {
gulp
.src(config.toWatch.coffee)
.pipe(concat(config.outputFiles.coffee))
.pipe(coffee({base: true}).on('error', gutil.log))
.pipe(browserify({
transform: ['coffeeify'],
extensions: ['.coffee'],
paths: ['./assets/coffee/']
}))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(config.outputDirs.js))
});
gulp.task('css', function() {
return gulp
.src(config.toWatch.mainSass)
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(concat(config.outputFiles.sass))
.pipe(uglifycss())
.pipe(gulp.dest(config.outputDirs.css));
});
gulp.task('watchFiles', function() {
gulp.watch(config.toWatch.coffee).on("change", function(file) {
gulp.start('scripts');
});
gulp.watch(config.toWatch.sass, {interval: 500}).on("change", function(file) {
gulp.start('css');
});
});
gulp.task('default', ['scripts', 'css', 'watchFiles']);
gulp.task('build', ['scripts', 'css']);
gulp.task('watch', ['scripts', 'css', 'watchFiles']);