-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (90 loc) · 2.93 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var gutil = require('gulp-util');
var stripCssComments = require('gulp-strip-css-comments');
var minifyCss = require('gulp-minify-css');
var clean = require('gulp-clean');
var beep = require('beepbeep');
var preprocess = require('gulp-preprocess')
var preprocess_context;
var onError = function (err) {
beep([0]);
gutil.log(gutil.colors.green(err));
};
gulp.task('clean', function () {
gulp.src('build/*', {
read: false
})
.pipe(clean({
force: true
}));
});
gulp.task('index', function () {
gulp.src(['src/*.html'])
.pipe(preprocess(preprocess_context))
.pipe(gulp.dest('./build'));
gulp.src(['src/*.ico'])
.pipe(gulp.dest('./build'))
});
// gulp.task('js-min', function() {
// return gulp.src(['src/js/**/*.js', 'src/js/helpers/**/*.js', 'src/js/libs/**/*.js', 'src/js/views/**/*.js'])
// .pipe(uglify())
// .pipe(rename({
// extname: '.min.js'
// }))
// .pipe(preprocess(preprocess_context))
// .pipe(gulp.dest('./build/js'))
// });
gulp.task('js-reg', function() {
return gulp.src(['src/js/**/*.js', 'src/js/helpers/**/*.js', 'src/js/libs/**/*.js', 'src/js/views/**/*.js'])
.pipe(uglify())
.pipe(preprocess(preprocess_context))
.pipe(gulp.dest('./build/js'))
})
gulp.task('styles', function () {
gulp.src('src/scss/**/*.scss')
.pipe(plumber({
errorHandler: onError
}))
.pipe(sass({
errLogToConsole: true
}))
// .pipe(stripCssComments())
.pipe(gulp.dest('./build/css'));
});
gulp.task('assets', function () {
gulp.src(['src/img/**/*'])
.pipe(gulp.dest('./build/img'))
gulp.src(['src/fonts/**/*'])
.pipe(gulp.dest('./build/fonts'))
gulp.src(['src/templates/**/*.html'])
.pipe(gulp.dest('./build/templates'))
});
gulp.task('projects', function () {
gulp.src(['src/js/**/*.json'])
.pipe(gulp.dest('./build/js'))
});
gulp.task('minify-css', function () {
return gulp.src('build/css/**/*.css')
.pipe(minifyCss({
compatibility: 'ie9'
}))
.pipe(gulp.dest('./build/css'));
});
gulp.task('build', ['index', 'js-reg', 'styles', 'assets', 'projects', 'minify-css']);
gulp.task('watch', function () {
gulp.watch(['src/js/**/*.js', 'src/js/helpers/**/*.js', 'src/js/libs/**/*.js', 'src/js/views/**/*.js'], ['js-reg']);
// gulp.watch(['src/js/**/*.js', 'src/js/helpers/**/*.js', 'src/js/libs/**/*.js', 'src/js/views/**/*.js'], ['js-min']);
gulp.watch('src/**/*.html', ['index']);
gulp.watch('src/js/**/*.json', ['projects']);
gulp.watch(['src/img/**/*', 'src/fonts/**/*', 'src/templates/**/*.html'], ['assets'])
gulp.watch(['src/scss/**/*.scss', 'src/scss/libs/**/*.scss'], ['styles']);
gulp.watch('build/**/*.css' ['minify-css']);
});
gulp.task('default', ['build', 'watch'])
// gulp.task('preview', ['preview-build', 'watch'])
// gulp.task('debug', ['debug-build', 'watch'])
// gulp.task('release', ['release-build', 'watch'])