-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (61 loc) · 1.58 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';
// General
const gulp = require('gulp');
const clean = require('gulp-clean');
const sourcemaps = require('gulp-sourcemaps');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const log = require('gulplog');
// SASS
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
// JS
const browserify = require('browserify');
const babel = require('gulp-babel');
function defaultTask(cb) {
cleanDist();
style();
js();
watch();
cb();
}
function watch() {
gulp.watch("./src/scss/**/*.scss", style);
gulp.watch("./src/js/**/*.js", js);
}
function cleanDist() {
return gulp.src([
"./css/**/*",
"./js/**/*"
], {read:false})
.pipe(clean());
}
function style() {
return gulp.src("./src/scss/*.scss")
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({cascade: false}))
.pipe(sourcemaps.write())
.pipe(gulp.dest("./css/"))
}
function js() {
var b = browserify({
entries: './src/js/footer.js',
debug: true
});
return b.bundle()
.on('error', function(err){
console.log(err.message);
this.emit('end');
})
.pipe(source("footer.js"))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(babel({
presets: ["@babel/preset-env"]
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest("./js/"))
}
exports.default = defaultTask;
exports.clean = cleanDist;