-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (82 loc) · 2.34 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
84
85
86
87
88
89
90
91
92
93
const {watch, series, src, dest, parallel } = require('gulp');
const scss = require('gulp-sass')(require('sass'));
const environments = require('gulp-environments');
const minisite = require('gulp-minisite');
const plumber = require('gulp-plumber');
const concat = require('gulp-concat');
const prefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify-es').default;
const notify = require('gulp-notify');
const sourcemaps = require('gulp-sourcemaps');
const browserSync = require('browser-sync').create();
let development = environments.development;
let production = environments.production;
var destination = production() ? './dist/' : './temp/';
function css() {
return src('./src/assets/scss/*.scss')
.pipe(plumber())
.pipe(development(sourcemaps.init()))
.pipe(scss({
outputStyle: 'compressed'
}))
.on('error', function (err) {
notify().write(err);
this.emit('end');
})
.pipe(prefixer({
cascade: false
}))
.pipe(concat('styles.min.css'))
.pipe(development(sourcemaps.write('.')))
.pipe(dest(destination + 'assets/css/'))
.pipe(development(browserSync.stream()));
}
function js() {
return src('./src/assets/js/*.js')
.pipe(plumber())
.pipe(development(sourcemaps.init()))
.pipe(production(uglify()))
.pipe(concat('main.min.js'))
.pipe(development(sourcemaps.write('.')))
.pipe(dest(destination + 'assets/js/'));
}
function index() {
return src(['./src/**/*.yml', './src/**/*.md'])
.pipe(minisite())
.pipe(dest(destination));
}
function copy() {
return src(['./src/assets/img/*', './src/assets/pdf/*'], {base: 'src/', encoding: false})
.pipe(dest(destination));
}
function browsersyncServe(cb){
browserSync.init({
server: {
baseDir: './temp'
}
});
cb();
}
function browsersyncReload(cb){
browserSync.reload();
cb();
}
function watchTask() {
watch('./src/assets/scss/styles.scss', css);
watch('./src/assets/js/main.js', series(js, browsersyncReload));
watch(['./template/**/*.html', './src/**/*.yml', './src/**/*.md', './src/**/*.svg'], series(copy, index, browsersyncReload));
};
exports.build = series(
copy,
css,
js,
index,
);
exports.default = parallel(
copy,
css,
js,
index,
browsersyncServe,
watchTask
);