-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
53 lines (45 loc) · 1.3 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
const { src, dest, series, watch } = require('gulp')
const scssCompile = require('gulp-sass')(require('sass'))
const addCssPrefixer = require('gulp-autoprefixer')
const cssMinify = require('gulp-clean-css')
const scriptsMinify = require('gulp-terser')
const browsersync = require('browser-sync').create();
function styles() {
return src('./frontend/src/styles/**/*.scss')
.pipe(scssCompile())
.pipe(addCssPrefixer('last 2 versions'))
.pipe(cssMinify())
.pipe(dest('./frontend/dist/styles'))
}
function scripts() {
return src('./frontend/src/scripts/app.js')
// .pipe(scriptsMinify())
.pipe(dest('./frontend/dist/scripts'))
}
function images() {
return src('./frontend/src/images/**/*')
.pipe(dest('./frontend/dist/images'))
}
function browsersyncServe(cb) {
browsersync.init({ server: { baseDir: '.' }})
cb()
}
function browsersyncReload(cb) {
browsersync.reload()
cb()
}
function watchTask() {
watch('*.html', browsersyncReload)
watch([
'./frontend/src/styles/**/*.scss',
'./frontend/src/scripts/**/*.js',
'./frontend/src/images/**/*'],
series(styles, scripts, images, browsersyncReload))
}
exports.default = series(
styles,
scripts,
images,
browsersyncServe,
watchTask
)