-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (58 loc) · 1.75 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
'use strict'
const gulp = require('gulp');
const sass = require('gulp-sass')
const sourcemaps = require('gulp-sourcemaps')
const autoprefixer = require('gulp-autoprefixer')
const concat = require('gulp-concat')
const cssmin = require('gulp-cssmin')
const imagemin = require('gulp-imagemin')
const uglify = require('gulp-uglify')
const gulpIf = require('gulp-if')
const del = require('del')
const isDevelopment = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
const resultFolder = 'dist'
gulp.task('default', function () {
console.log('test')
})
gulp.task('fonts', () => {
return gulp.src(['src/css/fonts/*'], {base: 'src'})
.pipe(gulp.dest(resultFolder));
})
gulp.task('images', () => {
return gulp.src(['src/img/*'], {base: 'src'})
.pipe(imagemin())
.pipe(gulp.dest(resultFolder));
})
gulp.task('styles', () => {
return gulp.src('src/css/*.sass')
.pipe(gulpIf(isDevelopment, sourcemaps.init()))
.pipe(sass())
.pipe(autoprefixer())
.pipe(concat('styles.css'))
.pipe(gulpIf(isDevelopment, sourcemaps.write()))
.pipe(cssmin())
.pipe(gulp.dest(`${resultFolder}/css`));
})
gulp.task('js', () => {
return gulp.src(['src/js/*.js'])
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest(`${resultFolder}/js`));
})
gulp.task('php', () => {
return gulp.src(['src/*.php'])
.pipe(gulp.dest(resultFolder));
})
gulp.task('clean', () => {
return del(resultFolder)
})
gulp.task('build', gulp.series(
'clean',
gulp.parallel('fonts', 'images', 'styles', 'js', 'php')
))
gulp.task('watch', function () {
gulp.watch('src/css/**/*.sass', gulp.series('styles'))
gulp.watch('src/*.php', gulp.series('php'))
gulp.watch('src/js/*.js', gulp.series('js'))
})
gulp.task('dev', gulp.series('build', 'watch'))