-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
executable file
·83 lines (73 loc) · 2.2 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
'use strict'
const gulp = require('gulp'),
rename = require('gulp-rename'),
gulpif = require('gulp-if'),
sass = require('gulp-sass')(require('sass')),
cssmin = require('gulp-clean-css'),
uglify = require('gulp-uglify-es').default,
argv = require('yargs').argv,
fs = require('fs-extra'),
postcss = require('gulp-postcss');
const config = {
sourceMaps: !argv.production // --production
}
gulp.task(
'css:build',
async function () {
return gulp.src('./assets/css/*.scss')
.pipe(gulpif(config.sourceMaps, postcss([], { map: { inline: false } })))
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./assets/dist/css'))
.pipe(cssmin())
.pipe(
rename(
{
suffix: '.min',
}
)
)
.pipe(gulp.dest('./assets/dist/css'))
}
)
gulp.task(
'css:build:watch',
function () {
gulp.watch('./assets/css/*.scss', gulp.parallel('css:build'))
}
)
gulp.task(
'js:build',
async function () {
return gulp.src(['./assets/js/*.js'])
.pipe(gulp.dest('./assets/dist/js'))
.pipe(uglify())
.pipe(
rename(
function (path) {
path.extname = '.min.js'
}
)
)
.pipe(gulp.dest('./assets/dist/js'))
}
)
gulp.task(
'js:build:watch',
function () {
gulp.watch('./assets/js/*.js', gulp.parallel('js:build'))
}
)
gulp.task(
'watch',
gulp.parallel('js:build:watch', 'css:build:watch')
)
gulp.task(
'clean',
async function () {
fs.removeSync('./assets/dist')
}
)
gulp.task(
'build',
gulp.series('clean', 'css:build', 'js:build')
)