This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.js
72 lines (65 loc) · 1.63 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
'use strict'
const gulp = require('gulp')
const pkg = require('./package.json')
const autoprefixer = require('autoprefixer')
const cssnano = require('gulp-cssnano')
const header = require('gulp-header')
const postcss = require('gulp-postcss')
const rename = require('gulp-rename')
const sass = require('gulp-dart-sass')
const sourcemaps = require('gulp-sourcemaps')
const stripComments = require('gulp-strip-css-comments')
const cssDestDir = './lib'
const cssDestFile = 'Bits.css'
const cssDestFileMin = 'Bits.min.css'
const sassEntryFile = './src/styles/main.scss'
const sassSourceDir = './src/styles'
// Set banner template
const banner = [
'/*',
` ${pkg.name}`,
'',
` ${pkg.description}`,
'',
` Author: ${pkg.author.name}`,
` Author URI: ${pkg.author.url}`,
` Version: ${pkg.version}`,
'*/',
'',
'',
].join('\n')
const compileScss = () => {
return gulp
.src(sassEntryFile)
.pipe(sass().on('error', sass.logError))
.pipe(
header(banner, {
pkg: pkg,
})
)
.pipe(rename(cssDestFile))
.pipe(gulp.dest(cssDestDir))
.pipe(stripComments())
.pipe(sourcemaps.init())
.pipe(cssnano())
.pipe(
postcss([
autoprefixer({
flexbox: true,
grid: true,
}),
])
)
.pipe(
header(banner, {
pkg: pkg,
})
)
.pipe(rename(cssDestFileMin))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(cssDestDir))
}
const watch = () => gulp.watch(sassSourceDir + '/**/*', compileScss)
gulp.task('build', gulp.series(compileScss))
gulp.task('start', gulp.series(watch))
gulp.task('watch', gulp.series(watch))