-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
115 lines (96 loc) · 2.36 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
106
107
108
109
110
111
112
113
114
115
'use strict'
// Load gulp
var gulp = require('gulp');
// Modules container
var $ = {};
// Modules declaration
var modules = {
concat : 'gulp-concat',
del : 'del',
sass : 'gulp-ruby-sass',
minify_css : 'gulp-minify-css',
autoprefix : 'gulp-autoprefixer',
jshint : 'gulp-jshint',
rimraf : 'gulp-rimraf',
browserSync: 'browser-sync'
};
// Load all modules into modules container
for(var key in modules) {
if (modules.hasOwnProperty(key)) {
$[key] = require(modules[key]);
}
}
///////////////////////
// DEVELOPMENT TASKS //
///////////////////////
/////////////
// Scripts //
/////////////
/**
* Concatenates all bower dependencies in components folder
*/
gulp.task('vendor', function(){
// List of all dependencies
var dependencies = [
'bower_components/jquery/dist/jquery.js',
];
return gulp.src(dependencies)
.pipe($.concat('vendor.js'))
.pipe(gulp.dest('content/js/'));
});
/**
* Concatenates all application scripts in assets/js folder
*/
gulp.task('script', function(){
return gulp.src([
'content/js/**/*.js',
'!content/js/main.js',
'!content/js/vendor.js'
])
.pipe($.jshint())
.pipe($.jshint.reporter('default'))
.pipe($.concat('main.js'))
.pipe(gulp.dest('content'));
});
////////////
// Styles //
////////////
/**
* Compile style
*/
gulp.task('style', function() {
return gulp.src('./content/sass/main.sass')
.pipe($.sass({
'style': 'expanded',
'sourcemap=none': true,
'container':'gulp-ruby-sass'
}))
.pipe($.autoprefix('last 2 versions', '> 1%', 'ie 8'))
.pipe(gulp.dest('./content/css/'));
});
//////////////////
// Browser Sync //
//////////////////
gulp.task('serve', function (cb) {
$.browserSync({
files: ['./**/*.{js,css,html}'],
port: 8002,
notify: true,
server: {
baseDir: './',
index: 'index.html'
}
}, cb);
});
///////////////
// MAIN TASK //
///////////////
/**
* Sets watchers and triggers appropriate tasks
*/
gulp.task('default', ['vendor', 'script', 'style', 'serve'], function() {
// Watch for scripts changes
gulp.watch('./content/js/**/*.js', ['script']);
// Watch for SASS changes
gulp.watch('./content/sass/**/*.sass', ['style']);
});