This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgulpfile.js
102 lines (86 loc) · 3.21 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
'use strict';
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
concat = require('gulp-concat'),
autoprefixer = require('gulp-autoprefixer'),
mainBowerFiles = require('main-bower-files'),
gulpFilter = require('gulp-filter'),
merge = require('merge-stream'),
watch = require('gulp-watch'),
gulpif = require('gulp-if'),
del = require('del'),
livereload = require('gulp-livereload'),
templateCache = require('gulp-angular-templatecache'),
jshint = require('gulp-jshint'),
jshintstylish = require('jshint-stylish'),
angularFilesort = require('gulp-angular-filesort');
var assetsFolder = './app/assets/';
var assetsVendorFolder = assetsFolder + 'bower_components/';
var assetsJsFolder = assetsFolder + 'scripts/';
var assetsSassFolder = assetsFolder + 'styles/';
var assetsViewsFolder = assetsFolder + 'views/';
var assetsFontsFolder = assetsFolder + 'fonts/';
var assetsTemplatesFolder = assetsJsFolder + 'templates/';
var distFolder = './public/';
var distJsFolder = distFolder + 'scripts/';
var distCssFolder = distFolder + 'styles/';
var distFontsFolder = distFolder + 'fonts/';
gulp.task('styles', function() {
return sass(assetsSassFolder, { sourcemap: true })
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(concat('main.css'))
.pipe(gulp.dest('public/styles'));
});
gulp.task('scripts', function() {
return gulp.src(assetsJsFolder + '**/*.js')
.pipe(angularFilesort())
.pipe(concat('app.js'))
.pipe(gulp.dest('public/scripts'));
});
gulp.task('fonts', function () {
var fontAwesome = gulp.src(assetsVendorFolder + 'font-awesome/fonts/*');
var openSans = gulp.src(assetsFontsFolder + '/*');
return merge(fontAwesome, openSans)
.pipe(gulp.dest(distFontsFolder));
});
gulp.task('jshint', function() {
return gulp.src(assetsJsFolder + '**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(jshintstylish));
});
gulp.task('clean', function (cb) {
del([
distFolder + '**/*',
'!' + distFolder + 'index.php',
'!' + distFolder + '.htaccess'
], cb);
});
gulp.task('angular-templates', function () {
return gulp.src([assetsViewsFolder + '/**/*.html', assetsTemplatesFolder + '**/*.html'])
.pipe(templateCache({
module: 'gitPrettyStats.templates',
standalone: true
}))
.pipe(gulp.dest('public/scripts'));
});
gulp.task('vendor', function() {
var styles = gulp.src(mainBowerFiles())
.pipe(gulpFilter('*.css'))
.pipe(concat('vendor.css'))
.pipe(gulp.dest(distCssFolder));
var scripts = gulp.src(mainBowerFiles())
.pipe(gulpFilter('*.js'))
.pipe(concat('vendor.js'))
.pipe(gulp.dest(distJsFolder));
return merge(styles, scripts);
});
gulp.task('watch', ['default'], function () {
livereload.listen();
gulp.watch(assetsSassFolder + '**/*.scss', ['styles']);
gulp.watch(assetsJsFolder + '**/*.js', ['scripts', 'jshint']);
gulp.watch([assetsViewsFolder + '**/*.html', assetsTemplatesFolder + '**/*.html'], ['angular-templates']);
gulp.watch(distFolder + '**/*').on('change', livereload.changed);
});
gulp.task('default', ['clean'], function () {
gulp.start(['styles', 'scripts', 'vendor', 'fonts', 'angular-templates']);
});