This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (50 loc) · 1.54 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
const fs = require('fs');
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sassglob = require('gulp-sass-glob');
const rename = require('gulp-rename');
const concat = require('gulp-concat');
const terser = require('gulp-terser');
const browserSync = require('browser-sync').create();
const package = JSON.parse(fs.readFileSync('./package.json'));
gulp.task('sass', () => gulp.src('src/scss/base.scss')
.pipe(sassglob())
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(autoprefixer({ cascade: false }))
.pipe(rename(`spartan-${package.version}.css`))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('kitchensink'))
);
gulp.task('javascript', () => gulp.src('src/javascript/**/*.js')
.pipe(concat(`spartan-${package.version}.js`))
.pipe(terser())
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('kitchensink'))
);
gulp.task('serve', () => {
browserSync.init({
open: false,
notify: false,
minify: false,
server: {
baseDir: './',
directory: true,
},
files: [
'dist/**/*',
'kitchensink/**/*'
],
});
});
const watchers = (done) => {
gulp.watch(['src/scss/**/*.scss'], {
awaitWriteFinish: true,
}).on('change', gulp.series('sass'));
gulp.watch(['src/javascript/**/*.js'], {
awaitWriteFinish: true,
}).on('change', gulp.series('javascript'));
done();
}
gulp.task('build', gulp.series('sass', 'javascript'));
gulp.task('dev', gulp.series('sass', 'javascript', gulp.parallel(watchers, 'serve')));