-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
100 lines (81 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
minifyCss = require('gulp-minify-css'),
bless = require('gulp-bless'),
notify = require('gulp-notify'),
bower = require('gulp-bower'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
jshint = require('gulp-jshint'),
jshintStylish = require('jshint-stylish'),
scsslint = require('gulp-scss-lint');
// browserSync = require('browser-sync').create(),
// reload = browserSync.reload;
var config = {
sassPath: './static/scss',
cssPath: './static/css',
jsPath: './static/js',
fontPath: './static/fonts',
// phpPath: './',
bowerDir: './static/components'
};
// Run Bower
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
.on('end', function() {
// Add Glyphicons to fonts dir
gulp.src(config.bowerDir + '/bootstrap-sass-official/assets/fonts/*/*')
.pipe(gulp.dest(config.fontPath));
});
});
// Compile scss files
gulp.task('css', function() {
return gulp.src(config.sassPath + '/*.scss')
.pipe(scsslint())
.pipe(sass().on('error', sass.logError))
.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(rename('style.min.css'))
.pipe(bless())
.pipe(gulp.dest(config.cssPath));
// .pipe(browserSync.stream());
});
// Lint, concat and uglify js files.
gulp.task('js', function() {
// Run jshint on all js files in jsPath (except already minified files.)
return gulp.src([config.jsPath + '/*.js', '!' + config.jsPath + '/*.min.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'))
.on('end', function() {
// Combine and uglify js files to create script.min.js.
var minified = [
config.bowerDir + '/bootstrap-sass-official/assets/javascripts/bootstrap.js',
config.bowerDir + '/placeholders/dist/placeholders.jquery.js',
config.bowerDir + '/imagesloaded/imagesloaded.pkgd.js',
config.bowerDir + '/matchHeight/jquery.matchHeight.js',
config.jsPath + '/generic-base.js',
config.jsPath + '/script.js'
];
gulp.src(minified)
.pipe(concat('script.min.js'))
.pipe(uglify())
.pipe(gulp.dest(config.jsPath));
});
});
// Rerun tasks when files change
gulp.task('watch', function() {
// browserSync.init({
// proxy: {
// target: "localhost/wordpress/faculty"
// }
// });
// gulp.watch(config.jsPath + '/*.js', ['js']).on('change', reload);
// gulp.watch(config.phpPath + '/*.php').on('change', reload);
// gulp.watch(config.phpPath + '/*.php');
gulp.watch(config.sassPath + '/*.scss', ['css']);
gulp.watch(config.jsPath + '/*.js', ['js']);
});
// Default task
gulp.task('default', ['bower', 'css', 'js']);