-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
112 lines (98 loc) · 2.79 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
// //////////////////////////////////////////
// Required
// //////////////////////////////////////////
var uglify = require('gulp-uglify'),
gulp = require('gulp'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
compass = require('gulp-compass'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
del = require('del'),
autoprefixer = require('gulp-autoprefixer');
// //////////////////////////////////////////
// Scripts Task
// //////////////////////////////////////////
gulp.task('scripts', function() {
gulp.src(['app/js/**/*.js', '!app/js/**/*.min.js'])
.pipe(rename({suffix:'.min'}))
.pipe(uglify())
.pipe(gulp.dest('app/js'))
.pipe(reload({stream:true}));
});
// //////////////////////////////////////////
// Compass/Sass Tasks
// //////////////////////////////////////////
gulp.task('compass', function(){
gulp.src('app/scss/style.scss')
.pipe(plumber())
.pipe(autoprefixer('last 2 versions'))
.pipe(compass({
config_file: './config.rb',
css: 'app/css',
sass: 'app/scss',
require: ['susy']
}))
.pipe(gulp.dest('app/css/'))
.pipe(reload({stream:true}));
});
// //////////////////////////////////////////
// HTML Tasks
// //////////////////////////////////////////
gulp.task('html', function(){
gulp.src('app/**/*.html')
.pipe(reload({stream:true}));
});
// //////////////////////////////////////////
// Build Tasks
// //////////////////////////////////////////
//clear out all files and folder from build folder
gulp.task('build:cleanfolder', function(cb){
del([
'build/**'
], cb());
});
//task to create build directory for all files
gulp.task('build:copy', ['build:cleanfolder'], function(){
return gulp.src('app/**/*/')
.pipe(gulp.dest('build/'));
});
//task to remove unwanted build files
//list all files and directories here that you don't want to include
gulp.task('build:remove', ['build:copy'], function(cb){
del([
'build/scss/',
'build/js/!(*.min.js)'
], cb());
});
gulp.task('build', ['build:copy', 'build:remove']);
// //////////////////////////////////////////
// Browser-Sync Tasks
// //////////////////////////////////////////
gulp.task('browser-sync', function(){
browserSync({
server: {
baseDir: "./app/"
}
});
});
//task to run build server for testing final app
gulp.task('build:serve', function(){
browserSync({
server: {
baseDir: "./build/"
}
});
});
// //////////////////////////////////////////
// Watch Tasks
// //////////////////////////////////////////
gulp.task('watch', function(){
gulp.watch('app/js/**/*.js', ['scripts']);
gulp.watch('app/scss/**/*.scss', ['compass']);
gulp.watch('app/**/*.html', ['html']);
});
// //////////////////////////////////////////
// Default Task
// //////////////////////////////////////////
gulp.task('default', ['scripts','html', 'compass', 'browser-sync', 'watch']);