-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
66 lines (57 loc) · 1.72 KB
/
Copy pathGulpfile.js
File metadata and controls
66 lines (57 loc) · 1.72 KB
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
const { src, dest, series, watch } = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const autoPrefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const sourcemaps = require('gulp-sourcemaps');
const cache = require('gulp-cached');
const dependents = require('gulp-dependents');
// const size = require('gulp-size');
const browsersync = require('browser-sync').create();
const terser = require('gulp-terser');
function stylesTask() {
const stylesSource = './src/sass/**/*.scss';
const stylesDest1 = './docs/css/';
// const stylesDest2 = '/Volumes/htdocs/events/css';
// const sizefull = size({ showFiles: true, uncompressed: true });
// const sizegzip = size({ showFiles: true, gzip: true });
return src(stylesSource)
.pipe(cache('sasscache'))
.pipe(dependents())
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoPrefixer({ grid: false }))
.pipe(cleanCSS({ format: 'compress' }))
// .pipe(sizefull)
// .pipe(sizegzip)
.pipe(sourcemaps.write())
.pipe(dest(stylesDest1));
}
function scriptsTask(){
const scriptsSource = './src/js/*.js';
const scriptsDest1 = './docs/js/';
return src(scriptsSource, { sourcemaps: true })
.pipe(terser())
.pipe(dest(scriptsDest1, { sourcemaps: '.' }));
}
function browsersyncServe(cb) {
browsersync.init({
server: {
baseDir: 'docs/'
}
});
cb();
}
function browsersyncReload(cb) {
browsersync.reload();
cb();
}
function watchTask() {
watch('./docs/*.html', browsersyncReload);
watch(['./src/sass/**/*.scss', './src/js/*.js'], series(stylesTask, scriptsTask, browsersyncReload))
}
exports.default = series(
stylesTask,
scriptsTask,
browsersyncServe,
watchTask
);