-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathgulpfile.js
72 lines (64 loc) · 1.96 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var notify = require('gulp-notify');
var cleanCSS = require('gulp-clean-css');
var minifyJS = require('gulp-minify');
var rename = require('gulp-rename');
var webserver = require('gulp-webserver');
var runSequence = require('run-sequence');
gulp.task('scss', function () {
return gulp.src('./src/scss/countrySelect.scss')
.pipe(sass({ errLogToConsole: true }))
.pipe(prefix())
.pipe(cleanCSS({compatibility: 'ie8', format: {
breaks: {
afterAtRule: true,
afterBlockBegins: true,
afterBlockEnds: true,
afterComment: true,
afterProperty: true,
afterRuleBegins: true,
afterRuleEnds: true,
beforeBlockEnds: true,
betweenSelectors: true
},
indentBy: 1,
indentWith: 'tab' }, level: 0}))
.pipe(gulp.dest('./build/css'))
.pipe(notify("styles compiled"));
});
gulp.task('js', function () {
return gulp.src('./src/js/countrySelect.js')
.pipe(gulp.dest('./build/js'))
.pipe(notify("javascript updated"));
});
gulp.task('handle-sources', ['scss', 'js']);
gulp.task('minify-scss', function () {
return gulp.src('./build/css/countrySelect.css')
.pipe(cleanCSS({level: 2, inline: ['all']}))
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('./build/css'))
.pipe(notify("styles minified"));
});
gulp.task('minify-js', function () {
return gulp.src('./build/js/countrySelect.js')
.pipe(minifyJS({ext:{min:'.min.js'}}))
.pipe(gulp.dest('./build/js'))
.pipe(notify("javascript minified"));
});
gulp.task('minify-sources', ['minify-scss', 'minify-js']);
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
livereload: true,
directoryListing: true,
open: './demo.html'
}));
gulp.watch('./src/scss/**/*.scss', ['scss']);
gulp.watch('./src/js/**/*.js', ['js']);
});
gulp.task('default', ['handle-sources', 'webserver']);
gulp.task('build', function() {
runSequence('handle-sources', 'minify-sources');
});