-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (62 loc) · 1.55 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
var autoprefixer = require('gulp-autoprefixer');
var gulp = require('gulp');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var Path = {
CSS_SOURCES: [
'./themes/*/sass/**'
],
CSS_OUT_DIR: './dist/css/',
JS_SOURCES: './themes/material/js/*.js',
JS_OUT_DIR: './dist/js/',
};
var onError = function() {
var args = Array.prototype.slice.call(arguments);
console.log(args);
this.emit('end');
};
gulp.task('buildcss', function(callback) {
return runSequence(
'sass',
callback
);
});
gulp.task('sass', function() {
return gulp.src('./themes/*/sass/*.scss')
.pipe(plumber())
.pipe(sass({
outputStyle: 'compressed'
}))
.on('error', onError)
.pipe(autoprefixer({
'browsers': [
'> 1%',
'last 2 versions',
'Firefox ESR',
'Opera 12.1',
'iOS 7'
]
}))
.pipe(gulp.dest(Path.CSS_OUT_DIR));
});
gulp.task('minifyjs', function() {
return gulp.src([
'./node_modules/smooth-scroll/dist/js/smooth-scroll.js',
Path.JS_SOURCES,
])
.pipe(uglify({
mangle: false,
compress: true,
}))
.pipe(concat('main.min.js'))
.pipe(gulp.dest(Path.JS_OUT_DIR));
});
gulp.task('watch', function() {
gulp.watch(Path.CSS_SOURCES, ['buildcss']);
gulp.watch(Path.JS_SOURCES, ['minifyjs']);
});
gulp.task('build', ['buildcss', 'minifyjs']);
gulp.task('default', ['build', 'watch']);