-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
99 lines (83 loc) · 2.17 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
//node modules
var path = require('path');
var fs = require('fs');
//gulp modules
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var stripDebug = require('gulp-strip-debug');
//var imagemin = require('gulp-imagemin');
var mysitepath = "../bootstrap_mysite";
var ismysite = fs.existsSync(mysitepath);
var root = ismysite ? mysitepath : "";
var inputs = {
bower: "bower_components",
node: "node_modules",
less: "less",
js: "javascript"
}
var outputs = {
css: path.join(root, "css"),
js: path.join(root, "javascript"),
fonts: path.join(root,"fonts")
};
gulp.task('less', function(){
var files = [inputs.less + '/site.less'];
if(ismysite) {
files.push(
path.join(mysitepath, "less/custom.less")
);
}
return gulp.src(files)
.pipe(concat("site.less")) //join less files into one
.pipe(sourcemaps.init())
.pipe(less({
paths: [
'bower_components',
'less'
]
//TODO: add plugins
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(outputs.css));
});
gulp.task('scripts', function() {
// TODO: ordering etc
var files = [
inputs.bower + "/jquery/dist/jquery.js",
inputs.bower + "/velocity/velocity.js",
inputs.bower + "/modernizr/modernizr.js",
inputs.bower + "/bootstrap/dist/js/bootstrap.js",
inputs.bower + "/stellar.js/src/jquery.stellar.js",
inputs.bower + "/wow/dist/wow.js",
mysitepath + "/main.js"
];
// include code found in mysite
// TODO: ordering
if(ismysite) {
files.push(path.join(mysitepath, "javascript/**/*.js"));
files.push("!" + path.join(mysitepath, "javascript/**/*.min.js"));
}
return gulp.src(files)
.pipe(sourcemaps.init())
.pipe(jshint())
.pipe(concat('site.min.js'))
.pipe(stripDebug())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(outputs.js));
});
gulp.task('watch', function() {
gulp.watch([
inputs.less + "/**/*.less",
mysitepath + "/less/**/*.less"
], ['less']);
gulp.watch([
mysitepath + "/**/*.js",
"!"+mysitepath + "/**/*.min.js"
], ['scripts']);
});
gulp.task('default', ['watch', 'less', 'scripts']);