-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
119 lines (98 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var minify = require('gulp-cssnano');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var imagemin = require('gulp-imagemin');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var livereload = require('gulp-livereload');
var changed = require('gulp-changed');
var svgmin = require('gulp-svgmin');
var sourcemaps = require('gulp-sourcemaps');
var fs = require('node-fs');
var fse = require('fs-extra');
var json = require('json-file');
var plugins = require('gulp-load-plugins')({
camelize: true
}),
lr = require('tiny-lr'),
server = lr();
// Lint Task
gulp.task('lint', function() {
gulp.src(['js/*.js',
'themes/parallax-pro/js/*.js'
])
.pipe(plumber(plumberErrorHandler))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(plugins.notify({
message: 'Lint task complete'
}));
});
var gulp = require('gulp');
gulp.task('svgmin', function() {
return gulp.src('img/*.svg')
.pipe(svgmin())
.pipe(gulp.dest('img/dist'));
});
gulp.task('sass', function() {
gulp.src('sass/parallaxchild-styles.scss')
.pipe(plumber(plumberErrorHandler))
.pipe(sourcemaps.init()) // Process the original sources
.pipe(sass())
.pipe(autoprefixer())
.pipe(minify())
.pipe(sourcemaps.write()) // Add the map to modified source.
.pipe(gulp.dest(""))
.pipe(plugins.notify({
message: 'Styles task complete'
}));
});
gulp.task('plugin-scripts', function() {
gulp.src('*.js')
.pipe(plumber(plumberErrorHandler))
.pipe(rename({
suffix: '.min'
}))
.pipe(uglify())
.pipe(gulp.dest('js/'))
.pipe(plugins.notify({
message: 'Scripts task complete'
}));
});
gulp.task('images', function() {
gulp.src('img/*.{png,jpg,gif}')
.pipe(plumber(plumberErrorHandler))
.pipe(changed('img/'))
.pipe(plugins.imagemin({
optimizationLevel: 7,
progressive: true,
interlaced: true
}))
.pipe(gulp.dest('../images'))
.pipe(livereload())
.pipe(plugins.notify({
message: 'Images task complete'
}));
});
/* Error Handler */
var plumberErrorHandler = {
errorHandler: notify.onError({
title: 'Gulp',
message: 'Error: <%= error.message %>'
})
};
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('*.svg', ['svgmin']);
gulp.watch('sass/*.scss', ['sass']);
gulp.watch('*.js', ['plugin-scripts']);
gulp.watch('plugins/parallaxchild/*.js', ['plugin-scripts']);
});
// Default task
gulp.task('default', ['watch']);