This repository has been archived by the owner on Nov 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
/
gulpfile.js
66 lines (60 loc) · 1.74 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
/* eslint-env node */
const project = require('./package.json');
const { src, dest, series, watch } = require('gulp');
const browsersync = require('browser-sync').create();
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const minifycss = require('gulp-clean-css');
const rename = require('gulp-rename');
const sassGlob = require('gulp-sass-glob');
const plumber = require('gulp-plumber');
const zip = require('gulp-zip');
function reloadBrowsers(done) {
browsersync.reload();
done()
}
function compileCSS() {
'use strict';
return src('sass/main.scss')
.pipe(plumber())
.pipe(sourcemaps.init({largeFile: true}))
.pipe(rename({
basename: 'style'
}))
.pipe(sassGlob())
.pipe(sass())
.pipe(autoprefixer({ grid: true }))
.pipe(sourcemaps.write())
.pipe(dest('assets/css/'))
.pipe(minifycss())
.pipe(sourcemaps.write())
.pipe(rename({
extname: '.min.css'
}))
.pipe(dest('assets/css/'))
.pipe(browsersync.reload({stream: true}));
}
function serve() {
'use strict';
browsersync.init({
logPrefix: 'Saga for Ghost',
port: 3000
});
watch('sass/**/*.scss', compileCSS);
watch(['./*.hbs', './partials/*.hbs'], reloadBrowsers);
watch('assets/**/*.js', reloadBrowsers);
}
function createPackage() {
return src([
'./**',
'!node_modules/**',
'!./**.zip'
])
.pipe(zip('Saga-' + project.version + '.zip'))
.pipe(dest('./'));
}
exports.default = series(compileCSS, serve);
exports.compileCSS = compileCSS;
exports.serve = serve;
exports.createPackage = createPackage