This repository has been archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (65 loc) · 2.13 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var babel = require('gulp-babel');
var sass = require('gulp-sass');
var less = require('gulp-less-sourcemap');
// Static Server
gulp.task('serve', function() {
browserSync.init({
server: "."
});
});
// Watching scss/less/html files
gulp.task('watch', ['serve', 'babel', 'sass'/*, 'less'*/], function() {
gulp.watch("assets/babel/*.js", ['babel']);
gulp.watch("assets/scss/*.scss", ['sass']);
//gulp.watch("assets/less/*.less", ['less']);
gulp.watch("*.html").on('change', browserSync.reload);
});
//Compile BABEL into JS & auto-inject into browsers
gulp.task('babel', function() {
return gulp.src('assets/babel/*.js')
.pipe(babel({
presets: ['env']
}))
.on('error', function(err) {
console.log('[Compilation Error]');
console.log(err.fileName + ( err.loc ? `( ${err.loc.line}, ${err.loc.column} ): ` : ': '));
console.log('error Babel: ' + err.message + '\n');
console.log(err.codeFrame);
this.emit('end');
})
.pipe(gulp.dest('assets/js'))
.pipe(browserSync.stream());
});
// Compile SASS into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("assets/scss/*.scss")
.pipe(sass({
sourceComments: 'map',
sourceMap: 'scss'
}))
.on('error', function(err) {
console.log('[Compilation Error]');
//console.log(err.fileName + ( err.loc ? `( ${err.loc.line}, ${err.loc.column} ): ` : ': '));
console.log('error Babel: ' + err.message + '\n');
//console.log(err.codeFrame);
this.emit('end');
})
.pipe(gulp.dest("assets/css"))
.pipe(browserSync.stream());
});
// Compile LESS into CSS & auto-inject into browsers
/*gulp.task('less', function() {
return gulp.src("assets/less/*.less")
.pipe(less({
sourceMap: {
sourceMapRootpath: './assets/less' // Optional absolute or relative path to your LESS files
}
}))
.pipe(gulp.dest("assets/css"))
.pipe(browserSync.stream());
});*/
gulp.task('default', ['serve']);
gulp.task('server', ['serve']);
gulp.task('dev', ['watch']);