forked from meyvn/mdl-selectfield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (62 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
73
(function() {
'use strict';
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
sassFiles = ['./src/**/*.scss'],
uglify = require('gulp-uglifyjs'),
jsFiles = ['src/**/*.js'];
var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
gulp.task('sass', function () {
gulp
.src(sassFiles)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(rename(function(path) {
path.dirname = '';
path.basename = 'mdl-selectfield';
path.extname = '.min.css';
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./'));
});
gulp.task('uglify', function() {
gulp
.src(jsFiles)
.pipe(uglify('mdl-selectfield.min.js', {
outSourceMap: true
}))
.pipe(gulp.dest('./'));
});
function watch() {
gulp.watch(sassFiles, ['sass']);
gulp.watch(jsFiles, ['uglify']);
}
gulp.task('watch', function () {
watch();
});
gulp.task('serve', function() {
$.connect.server({
root: './',
port: 5000,
livereload: true
});
watch();
});
gulp.task('build', ['sass', 'uglify']);
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['watch']);
})();