-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (93 loc) · 2.95 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* --------- plugins --------- */
var gulp = require('gulp'),
compass = require('gulp-compass'),
jade = require('gulp-jade'),
coffee = require('gulp-coffee'),
minifyCSS = require('gulp-minify-css'),
uglifyJS = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
browserSync = require('browser-sync').create(),
plumber = require('gulp-plumber');
/* --------- paths --------- */
var paths = {
jade : {
location : 'dist/markups/**/*.jade',
compiled : 'dist/markups/_pages/*.jade',
destination : '.'
},
scss : {
location : 'dist/styles/**/*.scss',
entryPoint : 'css/main.css',
cssFiles : 'css/*.css'
},
coffee : {
location : 'dist/scripts/**/*.coffee',
jsFiles : 'js/*.js',
jsFolder : 'js',
jsFile : 'main.js'
},
compass : {
configFile : 'config.rb',
cssFolder : 'css',
scssFolder : 'dist/styles',
imgFolder : 'img'
},
browserSync : {
//baseDir : 'dist/',
watchPaths : ['*.html', 'dist/css/*.css', 'dist/js/*.js']
}
};
/* --------- jade --------- */
gulp.task('jade', function() {
gulp.src(paths.jade.compiled)
.pipe(plumber())
.pipe(jade({
pretty: '\t',
}))
.pipe(gulp.dest(paths.jade.destination));
});
/* --------- scss --------- */
gulp.task('scss', function() {
gulp.src(paths.scss.location)
.pipe(plumber())
.pipe(compass({
config_file: paths.compass.configFile,
css: paths.compass.cssFolder,
sass: paths.compass.scssFolder,
image: paths.compass.imgFolder
}))
.pipe(minifyCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(paths.compass.cssFolder));;
});
/* --------- coffee --------- */
gulp.task('coffee', function() {
gulp.src(paths.coffee.location)
.pipe(plumber())
.pipe(coffee({bare: true}))
.pipe(concat(paths.coffee.jsFile))
.pipe(gulp.dest(paths.coffee.jsFolder))
.pipe(uglifyJS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(paths.coffee.jsFolder));
});
/* --------- browser sync --------- */
gulp.task('sync', function() {
browserSync.init({
port: 9000,
browser: "google chrome",
server: {
baseDir: paths.browserSync.baseDir
}
});
});
/* --------- watch --------- */
gulp.task('watch', function(){
gulp.watch(paths.jade.location, ['jade']);
gulp.watch(paths.scss.location, ['scss']);
gulp.watch(paths.coffee.location, ['coffee']);
gulp.watch(paths.browserSync.watchPaths).on('change', browserSync.reload);
});
/* --------- default --------- */
gulp.task('default', ['sync', 'watch']);