-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (74 loc) · 3.1 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
var gulp = require('gulp'),
browserSync = require('browser-sync'), // Asynchronous browser loading on .scss file changes
reload = browserSync.reload,
autoprefixer = require('gulp-autoprefixer'), // Autoprefixing magic
minifycss = require('gulp-uglifycss'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
imagemin = require('gulp-imagemin'),
newer = require('gulp-newer'),
rimraf = require('gulp-rimraf'),
sass = require('gulp-sass'),
plumber = require('gulp-plumber'), // Helps prevent stream crashing on errors
ignore = require('gulp-ignore'), // Helps with ignoring files and directories in our run tasks
sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', function () {
return gulp.src('./public/assets/styles/**/*.scss')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(sass({
indentedSyntax: false
}))
.pipe(autoprefixer())
.pipe(gulp.dest('./public/assets/dist/styles'))
});
gulp.task('js_libs', function() {
return gulp.src('./public/assets/scripts/libs/**/*.js')
.pipe(concat('libs.js'))
.pipe(gulp.dest('./app/assets/javascripts'))
.pipe(uglify())
.pipe(gulp.dest('./app/assets/javascripts'))
.pipe(notify({ message: 'Vendor scripts task complete', onLast: true }));
});
gulp.task('js_app', function() {
return gulp.src('./public/assets/scripts/custom/*.js')
.pipe(concat('custom.js'))
.pipe(uglify())
.pipe(gulp.dest('./app/assets/javascripts/'))
.pipe(notify({ message: 'Custom scripts task complete', onLast: true }));
});
gulp.task('images', function() {
// Add the newer pipe to pass through newer images only
return gulp.src(['./public/assets/images/raw/**/*.{png,jpg,gif}'])
.pipe(newer('./public/assets/images/'))
.pipe(rimraf({ force: true }))
.pipe(imagemin({ optimizationLevel: 7, progressive: true, interlaced: true }))
.pipe(gulp.dest('./public/assets/images/'))
.pipe( notify( { message: 'Images task complete', onLast: true } ) );
});
// Watch Task
gulp.task('default', ['sass', 'js_libs', 'js_app'], function () {
var files = [
'**/*.php',
'**/*.{png,jpg,gif}'
];
browserSync.init(files, {
// Read here http://www.browsersync.io/docs/options/
proxy: 'localhost:3000',
// port: 8080,
// Tunnel the Browsersync server through a random Public URL
// tunnel: true,
// Attempt to use the URL "http://my-private-site.localtunnel.me"
// tunnel: "ppress",
// Inject CSS changes
injectChanges: true
});
gulp.watch('./public/assets/images/**/*', ['images']);
gulp.watch('./public/assets/styles/**/*.scss', ['sass', browserSync.reload]);
gulp.watch('./public/assets/scripts/**/*.js', ['js_app', browserSync.reload]);
});