-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
78 lines (61 loc) · 1.75 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
/*!
* gulp file
* Copyright 2020 MohammadReza Jelveh
* Licensed under MIT (https://github.com/mrjelveh/BootsDrac/blob/master/LICENSE)
*/
// Initialing packages
const autoprefixer = require('autoprefixer'),
cleanCSS = require('gulp-clean-css'),
{ src, dest, parallel, series, watch } = require('gulp'),
concat = require('gulp-concat'),
postcss = require('gulp-postcss'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
babel = require('gulp-babel'),
plumber = require('gulp-plumber');
// File path
const files = {
scssPath: 'scss/**/*.scss',
jsPath: 'js/**/*.js'
}
// SASS build & compiling
function scssTask() {
return src(files.scssPath)
.pipe(sass())
.pipe(dest('dist/css')) // output without compression
.pipe(cleanCSS())
.pipe(rename({
suffix: '.min'
}))
.pipe(dest('dist/css')) // output with compression
}
// JS Compiling
function jsTask() {
return src(files.jsPath)
.pipe(concat('main.js'))
.pipe(plumber())
.pipe(babel({
presets: [
['@babel/env', {
modules: false
}]
]
}))
.pipe(dest('dist/js')) // output without compression
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(dest('dist/js')) // output with compression
}
// Watch live changes 👁
function watchTask() {
watch([files.scssPath, files.jsPath],
parallel(scssTask, jsTask));
}
// Default
exports.default = series(
parallel(scssTask, jsTask),
watchTask
)