-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (70 loc) · 2.24 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const browserSync = require('browser-sync').create();
const imagemin = require('gulp-imagemin');
const pug = require('gulp-pug');
const autoprefixer = require('autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const del = require('del');
const runSequence = require('run-sequence');
const uglify = require('gulp-uglify');
gulp.task('sass', function () {
var plugins = [
autoprefixer({browsers: ['last 2 version']}),
cssnano()
];
return gulp.src('app/sass/*.scss') // Gets all files ending with .scss in app/scss
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(postcss(plugins))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream())
});
gulp.task('pug', function(){
return gulp.src('app/*.pug') // Gets all files ending with .pug in app/scss
.pipe(pug())
.pipe(gulp.dest('./'))
.pipe(browserSync.stream())
});
gulp.task('watch', ['sass', 'pug'], function () {
browserSync.init({
server: {
baseDir: './'
},
});
gulp.watch('app/sass/**/*.scss', ['sass', browserSync.reload]);
gulp.watch('app/js/**/*.js', ['js', browserSync.reload]);
gulp.watch('app/**/*.pug', ['pug']);
gulp.watch('./**/*.html').on('change', browserSync.reload);
gulp.watch('app/img/**/*.+(png|jpg|jpeg|gif|svg)', ['images', browserSync.reload])
});
gulp.task('js', function(){
return gulp.src('app/js/**/*.js')
//.pipe(uglify())
.pipe(gulp.dest('./js'))
});
gulp.task('clean:img', function() {
return del.sync('img');
})
gulp.task('images', function () {
runSequence('clean:img',
function() {
return gulp.src('app/img/**/*.+(png|jpg|jpeg|gif|svg)')
.pipe(gulp.dest('./img'))
})
});
gulp.task('fonts', function () {
return gulp.src('app/fonts/**/*.+(ttf|otf|svg)')
.pipe(gulp.dest('./fonts'))
});
gulp.task('css', function () {
return gulp.src('app/css/*.css')
.pipe(gulp.dest('./css'))
});
gulp.task('build', function() {
runSequence('clean:img',
['css', 'sass', 'images', 'pug', 'js', 'fonts', 'watch'])
});