Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
203 lines (186 loc) · 5.48 KB
/
Copy pathgulpfile.js
File metadata and controls
203 lines (186 loc) · 5.48 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
const { src, dest, parallel, series, watch } = require('gulp');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const uglify = require('gulp-uglify-es').default;
const sass = require('gulp-sass')(require('sass'));
const bourbon = require('node-bourbon');
const rename = require('gulp-rename');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const del = require('del');
const cache = require('gulp-cache');
// browserSync rules
function browsersync() {
browserSync.init({
server: { baseDir: 'app/' },
notify: true,
online: true
})
}
// expanded CSS compilation
function styles() {
return src('app/sass/**/*.sass')
.pipe(sass({
includePaths: bourbon.includePaths,
outputStyle: 'expanded'
}))
.pipe(autoprefixer({
overrideBrowserslist: [
'last 15 versions',
'ie >= 7',
'Firefox < 20'
],
grid: true
}))
.pipe(dest('app/css/'))
.pipe(browserSync.reload({stream: true}))
}
// minificated CSS compilation to source-files folder
function cssmin() {
return src('app/sass/**/*.sass')
.pipe(sass({ includePaths: bourbon.includePaths }))
.pipe(rename({ suffix: '.min', prefix : '' }))
.pipe(autoprefixer({
overrideBrowserslist: [
'last 15 versions',
'ie >= 7',
'Firefox < 20'
],
grid: true
}))
.pipe(cleanCSS())
.pipe(dest('dist/source-files/braxton-css-min-files/'))
}
// expanded CSS compilation to source-files folder
function cssexp() {
return src('app/sass/**/*.sass')
.pipe(sass({
includePaths: bourbon.includePaths,
outputStyle: 'expanded'
}))
.pipe(autoprefixer({
overrideBrowserslist: [
'last 15 versions',
'ie >= 7',
'Firefox < 20'
],
grid: true
}))
.pipe(dest('dist/source-files/braxton-css-files/'))
}
// HTML build
function html() {
return src('app/*.html')
.pipe(dest('dist/'))
}
// JS libs for template minification
function libs() {
return src([
'node_modules/jquery/dist/jquery.js',
'assets/modernizr/modernizr.js',
'node_modules/gsap/dist/gsap.js',
'node_modules/gsap/dist/ScrollTrigger.js',
'node_modules/bootstrap/dist/js/bootstrap.bundle.js',
'node_modules/lenis/dist/lenis.js',
'node_modules/imagesloaded/imagesloaded.pkgd.js',
'node_modules/swiper/swiper-bundle.js',
'node_modules/particles.js/particles.js',
'node_modules/photoswipe/dist/photoswipe.js',
'node_modules/photoswipe/dist/photoswipe-ui-default.js'
// 'assets/app.js'
])
.pipe(concat('libs.min.js'))
.pipe(uglify().on('error', console.error))
.pipe(uglify())
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
.pipe(dest('app/js/'))
.pipe(browserSync.stream())
}
// JS libs for demo minification
function libsdemo() {
return src([
'node_modules/jquery/dist/jquery.js',
'assets/modernizr/modernizr.js',
'node_modules/ajaxchimp/jquery.ajaxchimp.js',
'node_modules/gsap/dist/gsap.js',
'node_modules/gsap/dist/ScrollTrigger.js',
'node_modules/lenis/dist/lenis.js',
'node_modules/imagesloaded/imagesloaded.pkgd.js'
])
.pipe(concat('libsdemo.min.js'))
.pipe(uglify().on('error', console.error))
.pipe(uglify())
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
.pipe(dest('app/js/demo/'))
.pipe(browserSync.stream())
}
// expanded JS libs compilation to source-files folder
function libsexp() {
return src([
'node_modules/jquery/dist/jquery.js',
'assets/modernizr/modernizr.js',
'node_modules/gsap/dist/gsap.js',
'node_modules/gsap/dist/ScrollTrigger.js',
'node_modules/bootstrap/dist/js/bootstrap.bundle.js',
'node_modules/lenis/dist/lenis.js',
'node_modules/imagesloaded/imagesloaded.pkgd.js',
'node_modules/swiper/swiper-bundle.js',
'node_modules/particles.js/particles.js',
'node_modules/photoswipe/dist/photoswipe.js',
'node_modules/photoswipe/dist/photoswipe-ui-default.js'
// 'assets/app.js'
])
.pipe(concat('libs.js'))
.pipe(dest('dist/source-files/braxton-js-files/'))
}
// clean dist folder
function cleandist() {
return del(['dist/**'])
}
// files copy to dist
function buildcopy() {
return src([
'app/css/**/*.css',
'app/*.html',
'app/js/**/*.js',
'app/fonts/**/*',
'app/img/**/*',
'app/.htaccess',
'app/mail.php'
], { base: 'app', encoding: false })
.pipe(dest('dist'))
}
// app.js copy to dist
function buildalljs() {
return src([
//'assets/app.js',
'app/js/demo/demo.js',
'app/js/app.js',
'app/js/gallery-init.js'
])
.pipe(dest('dist/source-files/braxton-js-files/'))
}
// files watch
function startwatch() {
watch('app/**/*.html').on('change', browserSync.reload);
watch([ 'app/**/*.js', '!app/**/*.min.js' ], libs);
watch([ 'app/sass/**/*.sass' ], styles);
}
// clear cache
function clearcache() {
return cache.clearAll();
}
// all functions export
exports.browsersync = browsersync;
exports.libs = libs;
exports.libsdemo = libsdemo;
exports.libsexp = libsexp;
exports.styles = styles;
exports.cssmin = cssmin;
exports.cssexp = cssexp;
exports.html = html;
exports.clearcache = clearcache;
// build function
exports.build = series(cleandist, styles, cssmin, cssexp, html, libs, libsdemo, libsexp, buildcopy, buildalljs);
// default function (gulp)
exports.default = parallel(styles, libs, libsdemo, browsersync, startwatch);