-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathgulpfile.js
73 lines (64 loc) · 1.79 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'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
sassFiles = [
'./src/global.scss',
'./src/**/*.scss'
],
uglify = require('gulp-uglifyjs'),
jsFiles = ['src/**/*.js'];
gulp.task('sass-compress', function() {
gulp
.src(sassFiles)
.pipe(concat('file.scss'))
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(rename(function(path) {
path.dirname = '';
path.basename = 'mdl-selectfield';
path.extname = '.min.css';
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
});
gulp.task('sass', function () {
gulp
.src(sassFiles)
.pipe(concat('mdl-selectfield.scss'))
.pipe(sass({
sourceComments: false
}).on('error', sass.logError))
.pipe(gulp.dest('./dist'));
});
gulp.task('js-compress', function() {
gulp
.src(jsFiles)
.pipe(uglify('mdl-selectfield.min.js', {
outSourceMap: true
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('js', function() {
gulp
.src(jsFiles)
.pipe(rename(function(path) {
path.dirname = '';
path.basename = 'mdl-selectfield';
path.extname = '.js';
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function () {
gulp.watch(sassFiles, ['sass', 'sass-compress']);
gulp.watch(jsFiles, ['js', 'js-compress']);
});
gulp.task('build', ['sass', 'sass-compress', 'js', 'js-compress']);
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['watch']);
})();