-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
96 lines (86 loc) · 2.99 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
bowerFiles = require('main-bower-files'),
autoprefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
minifyCSS = require('gulp-minify-css'),
browserSync = require('browser-sync');
var paths = {
in : {
public : 'public/',
scripts : 'resources/js/',
sass : 'resources/sass/'
},
out : {
fonts : 'public/fonts',
public : 'public',
scripts : 'public/js',
styles : 'public/css'
}
};
var files = {
css : '*.css',
js : '*.js',
html : '*.html',
sass : '*/*.scss',
script : 'script.js',
style : 'style.scss'
};
gulp.task('styles', function() {
return gulp.src( paths.in.sass + files.style )
.pipe( sass({ errLogToConsole: true }) )
.pipe( autoprefixer('last 5 version') )
.pipe( rename({ suffix: '.min' }) )
.pipe( minifyCSS() )
.pipe( gulp.dest(paths.out.styles) )
.pipe( notify( function(file) {
return 'SASS Compiler file: '+ file.relative;
}) );
});
gulp.task('scripts', function() {
return gulp.src( paths.in.scripts + files.script )
.pipe( jshint('.jshintrc') )
.pipe( jshint.reporter('default') )
.pipe( rename({ suffix: '.min' }) )
.pipe( uglify() )
.pipe( gulp.dest(paths.out.scripts) )
.pipe( notify( function(file) {
return 'Scripts Compiler file: '+ file.relative;
}) );
});
gulp.task('bower_styles', function() {
return gulp.src( bowerFiles('**/' + files.css) )
.pipe( concat('components.min.css') )
.pipe( minifyCSS() )
.pipe( gulp.dest(paths.out.styles) )
.pipe( notify( function(file) {
return 'Bower CSS Compiler file: '+ file.relative;
}) );
});
gulp.task('bower_scripts', function() {
return gulp.src( bowerFiles('**/' + files.js) )
.pipe( concat('components.min.js') )
.pipe( uglify() )
.pipe( gulp.dest(paths.out.scripts) )
.pipe( notify( function(file) {
return 'Bower Compiler file: '+ file.relative;
}) );
});
gulp.task('browser_sync', function() {
browserSync.init(null, {
server: { baseDir: paths.out.public }
});
});
gulp.task('bs_reload', function() {
browserSync.reload();
});
gulp.task('watch', function() {
gulp.watch( paths.in.sass + files.sass, ['styles'] );
gulp.watch( paths.in.scripts + files.js, ['scripts'] );
gulp.watch( paths.in.app + files.html, ['bs_reload'] );
});
gulp.task('default', [ 'styles', 'scripts', 'bower_styles', 'bower_scripts', 'browser_sync', 'watch' ]);