This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
94 lines (73 loc) · 1.88 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
'use strict'
const connect = require('gulp-connect');
const del = require('del')
const gulp = require('gulp')
const runSequence = require('run-sequence')
const sass = require('gulp-sass')
const sourcemaps = require('gulp-sourcemaps')
const distributionPath = './dist'
const sassRelativePath = '/stylez'
const sourcePath = './src'
const allDistributionPath = `${distributionPath}/**/*`
const allSassPath = `${sourcePath}${sassRelativePath}/**/*.scss`
const allSourcePath = `${sourcePath}/**/*`
const sassEntryPath = `${sourcePath}${sassRelativePath}/main.scss`
const staticPath = [allSourcePath, `!${allSassPath}`]
// CLEANERS
gulp.task('clean:all', () => del(allDistributionPath))
gulp.task('clean:temp', () => del(`${distributionPath}${sassRelativePath}`))
// COPIERS
gulp.task('static:copy', () => (
gulp.src(allSourcePath)
.pipe(gulp.dest(distributionPath))
))
// COMPILERS
gulp.task('sass:compile', () => (
gulp.src(sassEntryPath)
.pipe(sourcemaps.init())
.pipe(sass()
.on('error', sass.logError)
)
.pipe(sourcemaps.write())
.pipe(gulp.dest(`${distributionPath}/css`))
))
// WATCHERS
gulp.task('watch', () => (
runSequence(
'clean:all',
'build',
[
'static:watch',
'sass:watch',
'livereload:watch',
'connect'
]
)
))
gulp.task('livereload:watch', () => (
gulp.watch(allDistributionPath, ['livereload'])
))
gulp.task('sass:watch', () => (
gulp.watch(allSassPath, ['sass:compile'])
))
gulp.task('static:watch', () => (
gulp.watch(staticPath, ['build'])
))
// SERVERS
gulp.task('connect', () => connect.server({
root: distributionPath,
livereload: true
}))
gulp.task('livereload', () => (
gulp.src(allDistributionPath)
.pipe(connect.reload())
))
// BUILDERS
gulp.task('build', ['sass:compile', 'static:copy'])
gulp.task('dist', () => (
runSequence(
'clean:all',
'build',
'clean:temp'
)
))