-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (56 loc) · 1.8 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
"use strict";
var gulp = require('gulp'),
watch = require('gulp-watch'),
inject = require('gulp-inject'),
postcss = require('gulp-postcss'),
imagemin = require('gulp-imagemin'),
minifyjs = require('gulp-js-minify'),
cleanCSS = require('gulp-clean-css'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer');
/* ==============================
css autoprefixer & minify -> src to dist
============================== */
gulp.task('prefix-css', function () {
return watch('./src/assets/css/src/*.css', { ignoreInitial: false })
.pipe(autoprefixer({
browsers: ['cover 99.5%'],
cascade: false
}))
.pipe(cleanCSS())
.pipe(gulp.dest('./src/assets/css/dist'));
});
/* ==============================
minify js
============================== */
gulp.task('jsmin', function () {
return watch('./src/assets/js/src/*.js', function () {
gulp.src('./src/assets/js/src/*.js')
.pipe(minifyjs())
.pipe(gulp.dest('./src/assets/js/dist'));
});
});
/* ==============================
image resizer
============================== */
gulp.task('img-resize', () =>
gulp.src('./src/assets/images/src/*')
.pipe(imagemin())
.pipe(gulp.dest('./src/assets/images/dist'))
);
/* ==============================
inject css/js
============================== */
gulp.task('inject', function () {
var target = gulp.src('./index.html');
var sources = gulp.src(['./src/assets/js/dist/*.js', './src/assets/css/dist/*.css'], {read: false});
return target.pipe(inject(sources))
.pipe(gulp.dest('./'));
});
/* ==============================
gulp watch
============================== */
gulp.task('watch', ['prefix-css',
'jsmin',
'inject',
'img-resize',])