forked from meyvn/mdl-selectfield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
88 lines (77 loc) · 1.92 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(function() {
'use strict';
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
bulkSass = require('gulp-sass-bulk-import'),
sassFiles = ['./src/**/*.scss'],
uglify = require('gulp-uglify'),
pump = require('pump'),
jsFiles = ['src/selectfield/*.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(bulkSass())
.pipe(sourcemaps.init())
.pipe(
sass({
includePaths: [
'./bower_components'
,'./node_modules'
],
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(cb) {
pump([
gulp.src(jsFiles)
,sourcemaps.init()
,uglify({outSourceMap: true})
,rename({
basename: 'mdl-selectfield',
suffix: '.min'
})
,sourcemaps.write('./')
,gulp.dest('./')
], cb);
});
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']);
})();