-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
80 lines (70 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var argv = require('yargs').argv;
var gulpif = require('gulp-if');
var rename = require('gulp-rename');
var gulp = require('gulp');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var postcss = require('postcss');
var sass = require('gulp-sass');
var coffee = require('gulp-coffee');
var autoprefixer = require('gulp-autoprefixer');
var replace = require('gulp-replace');
var php = require('gulp-connect-php');
var assets = '.asset';
var paths = {
sass: './asset/sass/*.scss',
coffee: './asset/coffee/*.coffee',
}
var dest = {
css: './asset/css/',
js: './asset/js/',
images: './asset/img/'
}
gulp.task('compile-sass', function() {
var sassOptions = {
compress: argv.prod ? true : false
};
var apOptions = {
browsers: ['> 0.5%', 'last 5 versions', 'Firefox ESR', 'not dead']
};
gulp.src(paths.sass)
.pipe(plumber())
.pipe(sass(sassOptions))
.pipe(autoprefixer(apOptions))
.pipe(replace('img/', dest.images))
.pipe(gulp.dest(dest.css))
.on('end', function() {
log('Sass done');
if (argv.prod) log('CSS minified');
});
});
gulp.task('compile-coffee', function() {
gulp.src(paths.coffee)
.pipe(coffee({bare: true}))
.pipe(gulp.dest(dest.js))
.on('end', function() {
log('Coffee done');
if (argv.prod) log('JS minified');
});
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['compile-sass']);
gulp.watch(paths.coffee, ['compile-coffee']);
});
gulp.task('default', [
'compile-sass',
'compile-coffee',
'watch'
]);
gulp.task('dev', [
'compile-sass',
'compile-coffee',
'watch'
]);
gulp.task('prod', [
'compile-sass',
'compile-coffee'
]);
function log(message) {
gutil.log(gutil.colors.bold.green(message));
}