-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (53 loc) · 1.45 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
var gulp = require('gulp');
var nunjucks = require('gulp-nunjucks');
var concat = require('gulp-concat');
var browserSync = require('browser-sync').create();
//var imagemin = require('gulp-imagemin');
//var pngquant = require('imagemin-pngquant');
var reload = browserSync.reload;
var cssmin = require('gulp-cssmin');
const autoprefixer = require('gulp-autoprefixer');
var path = {
css: 'src/styles/*.css',
html: 'src/templates/*.html',
js: 'src/scripts/*.js',
dist: {
css: 'dist/styles/',
html: 'dist/',
js: 'dist/scripts/'
}
};
gulp.task('default', ['build', 'serve', 'watch']);
gulp.task('css', function () {
return gulp.src(path.css)
.pipe(autoprefixer({
browsers: ['last 4 versions']
}))
.pipe(cssmin())
.pipe(concat('style.css'))
.pipe(gulp.dest(path.dist.css));
});
gulp.task('html', function () {
return gulp.src(path.html)
.pipe(nunjucks.compile())
.pipe(gulp.dest(path.dist.html));
});
gulp.task('js', function () {
return gulp.src(path.js)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(path.dist.js));
});
gulp.task('build', ['html', 'css', 'js']);
gulp.task('watch', function () {
gulp.watch(path.css, ['css']);
gulp.watch(path.html, ['html']);
gulp.watch(path.js, ['js']);
});
gulp.task('serve', ['watch'], function() {
browserSync.init({
server: {
baseDir: path.dist.html
}
});
gulp.watch('dist/**').on('change', browserSync.reload);
});