forked from maraoz/buzhi-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (104 loc) · 2.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const { series, dest, src, watch } = require('gulp')
const twig = require('gulp-twig')
const sourcemap = require('gulp-sourcemaps')
const browsersync = require('browser-sync').create()
const concat = require('gulp-concat')
const uglify = require('gulp-uglify')
const sass = require('gulp-sass')(require('sass'));
// const postcss = require('gulp-postcss');
// Template engine twig
function templateTask() {
return src('./src/**/*.twig')
.pipe(twig()).pipe(dest('dist'))
}
// SCSS Styles
function styleTask() {
return src('./src/assets/scss/*.scss')
.pipe(sourcemap.init())
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(sourcemap.write('.'))
.pipe(dest('dist/assets/css')).pipe(browsersync.stream())
}
// CSS Styles
function cssPluginTask() {
return src('./src/assets/css/*.css')
.pipe(concat('plugins.min.css'))
.pipe(dest('dist/assets/css'))
}
// CSS Styles
function videoTask() {
return src('./src/assets/video/**')
.pipe(dest('dist/assets/video'))
}
// Image asssets
function imageTask() {
return src('./src/assets/img/**')
.pipe(dest('dist/assets/img'))
}
function jsPluginsTask() {
return src(['./src/assets/js/plugin/*.js'])
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(dest('dist/assets/js'))
}
function jsDefaultTask(){
return src(['./src/assets/js/default/*.js'])
.pipe(concat('diffault.min.js'))
.pipe(uglify())
.pipe(dest('dist/assets/js'))
}
// Custom JS task
function customJsTask() {
return src('src/assets/js/scripts.js')
.pipe(dest('dist/assets/js'))
}
// Fonts file
function custonFonts() {
return src('src/assets/fonts/**')
.pipe(dest('dist/assets/fonts'))
}
// Live reload browsersync
function browsersyncServe(cb) {
browsersync.init({
server: {
baseDir: './dist'
}
})
cb()
}
// Watch all files
function watcher() {
watch('./src/**/*.twig').on("change", series(templateTask, browsersync.reload))
watch('./src/assets/img/**', imageTask)
watch('./src/assets/js/default/*.js', jsDefaultTask)
watch('./src/assets/js/plugin/*.js', jsPluginsTask)
watch('./src/assets/js/scripts.js', customJsTask)
watch('./src/assets/css/*.css', cssPluginTask)
watch('./src/assets/scss/**/*.scss', styleTask)
watch('./src/assets/fonts/**', custonFonts)
watch('./src/assets/video/**', videoTask)
}
exports.build = series(
templateTask,
styleTask,
cssPluginTask,
videoTask,
imageTask,
jsDefaultTask,
jsPluginsTask,
customJsTask,
custonFonts
)
exports.default = series(
templateTask,
styleTask,
cssPluginTask,
videoTask,
imageTask,
jsDefaultTask,
jsPluginsTask,
customJsTask,
custonFonts,
browsersyncServe,
watcher
)