-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
46 lines (39 loc) · 1.25 KB
/
gulpfile.js
File metadata and controls
46 lines (39 loc) · 1.25 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
'use strict';
var gulp = require('gulp'),
scss = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber');
var SASS_INCLUDE_PATHS = [
'./node_modules/normalize-scss/sass/'
];
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
gulp.task('styles', function () {
return gulp.src('./sass/main.scss')
.pipe(plumber({ errorHandler: handleError }))
.pipe(sourcemaps.init())
.pipe(scss({outputStyle: 'compressed', includePaths: SASS_INCLUDE_PATHS}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'));
});
gulp.task('js', function() {
return gulp.src('./source-js/**/*.js')
.pipe(plumber({ errorHandler: handleError }))
.pipe(sourcemaps.init())
.pipe(babel({compact: true}))
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./js'));
});
gulp.task('watch', ['styles', 'js'], function () {
gulp.watch('./sass/**/*.scss', ['styles']);
gulp.watch('./source-js/**/*.js', ['js']);
});
gulp.task('default', ['styles', 'js'], function () {
});