This repository was archived by the owner on Apr 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
116 lines (100 loc) · 2.43 KB
/
gulpfile.js
File metadata and controls
116 lines (100 loc) · 2.43 KB
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
106
107
108
109
110
111
112
113
114
115
116
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber');
var watch = require('gulp-watch');
var livereload = require('gulp-livereload');
var concat = require('gulp-concat');
var nib = require('nib');
var _ = require('lodash');
var path = require('path');
var fs = require('fs');
var bowerjs = []
var bowercss = [
"skeleton/css/normalize.css",
"skeleton/css/skeleton.css",
"octicons/octicons/octicons.css"
]
var bowercopy = [
"octicons/octicons/octicons.eot",
"octicons/octicons/octicons.woff",
"octicons/octicons/octicons.ttf",
"octicons/octicons/octicons.svg"
]
var prefix = function(b) {
return 'bower_components/' + b;
}
bowerjs = _.map(bowerjs, prefix);
bowercss = _.map(bowercss, prefix);
bowercopy = _.map(bowercopy, prefix);
gulp.task('stylus', function() {
gulp
.src('stylesheets/styles.styl')
.pipe(plumber())
.pipe(stylus({
compress: true,
use: nib(),
sourcemap: {
inline: true,
sourceRoot: '.',
basePath: 'public/build',
}
}))
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(sourcemaps.write('.', {
includeContent: false,
sourceRoot: '.'
}))
.pipe(gulp.dest('public/build'))
.pipe(livereload());
});
gulp.task('concat-js', function() {
gulp
.src(bowerjs)
.pipe(concat('bower.js'))
.pipe(gulp.dest('public/build'))
})
gulp.task('concat-css', function() {
gulp
.src(bowercss)
.pipe(concat('bower.css'))
.pipe(gulp.dest('public/build'))
})
gulp.task('concat', ['concat-js', 'concat-css'])
gulp.task('copy', function() {
_.each(bowercopy, function(f) {
var dest = 'public/build/';
var src = f;
if (fs.lstatSync(f).isDirectory()) {
dest += _.last(f.split('/'));
src += '/*';
}
gulp
.src(src)
.pipe(gulp.dest(dest))
});
})
gulp.task('bower', ['concat', 'copy'])
gulp.task('watch', ['bower', 'stylus'], function() {
livereload.listen({
port: 30002
});
var changed = function(file) {
var ext = path.extname(file.path);
switch(ext) {
case '.js': gulp.start('js'); break;
case '.html': gulp.start('html'); break;
case '.styl': gulp.start('stylus'); break;
}
}
var paths = [
'stylesheets/**/*.styl',
'views/*'
];
_.each(paths, function(path) {
watch(path, changed);
});
});
gulp.task('default', ['bower', 'stylus']);