-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
100 lines (88 loc) · 2.73 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
// Dependencies
var pkg = require('./package.json');
var config = require('./app_config.json');
var banner = require('gulp-banner');
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var sourcemaps = require('gulp-sourcemaps');
var stylish = require('jshint-stylish');
var phplint = require('gulp-phplint');
var rename = require('gulp-rename');
var size = require('gulp-size');
var browserSync = require('browser-sync').create();
var comment = ['/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>',
'<%= pkg.homepage ? pkg.homepage : "" %>',
'Copyright (c) <%= new Date().getFullYear() %> <%= pkg.author %>',
'Licensed <%= pkg.license %> */\n',
].join(' | ');
// Tasks
gulp.task('js-app', function() {
gulp.src(['js/lib/sticky-footer.js', 'js/src/*.js', '!js/src/customizer.js'])
.pipe(sourcemaps.init())
.pipe(concat('greatoutdoors.js'))
.pipe(rename('greatoutdoors.min.js'))
.pipe(uglify())
.pipe(banner(comment, {pkg: pkg}))
.pipe(size({gzip: true, showFiles: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('js/'))
});
gulp.task('sass', function() {
return gulp.src('sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: 'bower_components/foundation/scss',
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(autoprefixer({browsers: ['last 2 versions']}))
.pipe(size({gzip: true, showFiles: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./'))
});
gulp.task('jshint', function() {
gulp.src('js/src/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
});
gulp.task('js-customizer', function() {
gulp.src('js/src/customizer.js')
.pipe(rename('customizer.min.js'))
.pipe(uglify())
.pipe(gulp.dest('js/'))
});
gulp.task('phplint', function() {
gulp.src(['**/*.php', '!node_modules/**/*'])
.pipe(phplint())
});
gulp.task('watch', function() {
gulp.watch('sass/**/*.scss', ['sass']);
gulp.watch('js/**/*.js', ['jshint', 'js-app', 'js-customizer']);
gulp.watch('**/*.php', ['phplint']);
});
gulp.task('browser-sync', function() {
browserSync.init({
proxy: config['proxy'],
files: [
'*.css',
'js/**/*.js',
'**/*.php',
'images/*.jpg',
'images/*.png',
],
logLevel: 'debug',
});
});
// Dev and build tasks
gulp.task('default',function() {
gulp.start('browser-sync', 'watch');
});
gulp.task('build', function() {
gulp.start('js-app', 'js-customizer', 'sass');
});
gulp.task('lint', function() {
gulp.start('phplint', 'jshint');
});