-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
157 lines (116 loc) · 3.64 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Include Gulp & Tools
var gulp = require('gulp');
var del = require('del');
var jshint = require('gulp-jshint');
var watch = require('gulp-watch');
var haml = require('gulp-haml');
var sass = require('gulp-sass');
var minifycss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var browserSync = require('browser-sync');
var runSequence = require('run-sequence');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify')
var rename = require('gulp-rename');
var reload = browserSync.reload;
// HAML
gulp.task('haml', function() {
return gulp.src('app/index.haml')
.pipe(haml())
.pipe(gulp.dest('./public'));
});
// SASS
gulp.task('sass', function () {
return gulp.src('./app/styles/*.scss')
.pipe(sass())
.pipe(autoprefixer())
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('./public/styles'));
});
// Lint JavaScript
gulp.task('js', function(){
return gulp.src([
'./app/bower_components/angular/angular.js',
'./app/bower_components/angular-resource/angular-resource.js',
'./app/bower_components/angular-route/angular-route.js',
'./app/bower_components/angular-translate/angular-translate.js',
'./app/js/app.js',
// Shared Stuff
'./app/js/shared/filters.js',
'./app/js/shared/controllers.js',
'./app/js/shared/directives.js',
// Categories
'./app/js/category/categoryService.js',
'./app/js/category/categoryController.js',
'./app/js/category/categoryDirectives.js',
// Brands
'./app/js/brand/brandService.js',
'./app/js/brand/brandController.js',
'./app/js/brand/brandDirectives.js',
// Search
'./app/js/search/searchService.js',
'./app/js/search/searchController.js',
'./app/js/search/searchDirectives.js',
// Products
'./app/js/product/productService.js',
'./app/js/product/productController.js',
'./app/js/product/productDirectives.js'])
.pipe(jshint())
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/js'))
.pipe(jshint.reporter('default'));
});
// Images Min Task
gulp.task('images', function () {
return gulp.src('./app/images/**')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('./public/images'));
});
// Copy bower_components
gulp.task('copy:bower_components', function() {
return gulp.src('./app/bower_components/**/*')
.pipe(gulp.dest('./public/bower_components'));
});
// Copy Templates
gulp.task('copy:partials', function() {
return gulp.src('./app/partials/**/*')
.pipe(haml())
.pipe(gulp.dest('./public/partials'));
});
// Copy Fonts
gulp.task('copy:fonts', function() {
return gulp.src('./app/font/**/*')
.pipe(gulp.dest('./public/font'));
});
// Watch Files & Reload
gulp.task('serve', function() {
browserSync({
server: {
baseDir: "./public"
}
});
gulp.watch(['./app/index.haml'], ['haml', reload]);
gulp.watch('./app/styles/**/*.scss', ['sass', reload]);
gulp.watch('./app/js/**/*.js', ['js', reload]);
gulp.watch('./app/partials/**/*.haml', ['copy:partials', reload]);
});
// Clean the public Output Directory
gulp.task('clean', function() {
del(['public/*']);
});
// Build
gulp.task('build', ['clean'], function() {
runSequence('haml', 'sass', 'images', 'js', 'copy:bower_components', 'copy:partials', 'copy:fonts');
});
// Gulp Default
gulp.task('default', ['clean'], function() {
gulp.start('public');
});