-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
77 lines (66 loc) · 2.1 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
/**
* ----------------------------------------------------------------------
* Set Project Paths
* ----------------------------------------------------------------------
*/
const srcPath = './src/'
const staticPath = './static/'
const distPath = './dist/'
/**
* ----------------------------------------------------------------------
* Require and Initialize all Modules
* ----------------------------------------------------------------------
*/
let { src, dest, watch, series } = require('gulp')
let browserSync = require('browser-sync')
let rename = require('gulp-rename')
let sass = require('gulp-sass')(require('sass'))
let uglify = require('gulp-uglify')
/**
* ----------------------------------------------------------------------
* Tasks
* ----------------------------------------------------------------------
*/
function buildScss() {
return src(srcPath + 'scss/**/*.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(rename({ suffix: '.min' }))
.pipe(dest(distPath + 'css/'))
}
function buildJS() {
return src(srcPath + 'js/**/*.js')
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(dest(distPath + 'js/'))
}
function buildHTML() {
return src(srcPath + 'html/**/*.html')
.pipe(dest(distPath))
}
function buildStatic() {
return src(staticPath + '**/*')
.pipe(dest(distPath))
}
/**
* ----------------------------------------------------------------------
* Define exports/tasks
* ----------------------------------------------------------------------
*/
exports.default = () => {
browserSync.init(['*.css', '*.scss'], {
server: {
baseDir: "./dist"
}
});
watch(srcPath + 'js/**/*.js', buildJS)
watch(srcPath + 'scss/**/*.scss', buildScss)
watch(srcPath + 'html/**/*.html', buildHTML)
watch(staticPath + '**/*', buildStatic)
watch([srcPath + 'html/**/*.html', srcPath + 'js/**/*.js', srcPath + 'scss/**/*.scss']).on('change', browserSync.reload)
}
exports.build = series([
buildJS,
buildScss,
buildHTML,
buildStatic
])