-
Notifications
You must be signed in to change notification settings - Fork 579
/
gulpfile.js
81 lines (70 loc) · 2.73 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
(function () {
'use strict';
var gulp = require('gulp'),
gutil = require("gulp-util"),
del = require('del'),
beautify = require("gulp-jsbeautifier"),
uglify = require("gulp-uglify"),
cleanCSS = require('gulp-clean-css'),
rename = require("gulp-rename"),
header = require('gulp-header'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create();
var pkg = require('./package.json');
var banner = ['/**',
' * <%= pkg.name %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task('beautify', function() {
gulp.src(['./src/*.css', './src/*.js'])
.pipe(beautify())
.pipe(gulp.dest('./src'));
});
gulp.task('dist:clean', function () {
del.sync('./dist', {force: true});
del.sync('./src/*.css', {force: true});
});
gulp.task('dist:sass', ['dist:clean'], function() {
return gulp
.src(['./src/*.scss'])
.pipe(sass({outputStyle: 'expanded'}))
.pipe(autoprefixer({browsers: ['last 2 versions', 'ie 8']}))
.pipe(gulp.dest('./dist'));
});
gulp.task('dist:styles', ['dist:clean', 'dist:sass'], function () {
return gulp.src('./dist/*.css')
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(rename('daterangepicker.min.css'))
.pipe(gulp.dest('./dist'))
.on('error', gutil.log)
});
gulp.task('dist:script', ['dist:clean'], function () {
return gulp.src('./src/*.js')
.pipe(uglify())
.pipe(rename('jquery.daterangepicker.min.js'))
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('./dist'))
.on('error', gutil.log)
});
gulp.task('dev:serve', ['dist:clean', 'dist:sass', 'dist:styles'], function() {
browserSync.init({
port: 3000,
server: "./"
});
gulp.watch('./src/*.scss', ['simple-sass']);
gulp.watch('./*.html').on('change', browserSync.reload);
});
gulp.task('default', ['dist:clean', 'dist:sass', 'dist:styles', 'dist:script'], function (cb) {
gutil.log('Info :', gutil.colors.green('Distribution files v.' + pkg.version + ' are ready!'));
cb(null)
});
gulp.task('dev', ['dist:clean', 'dist:sass', 'dist:styles', 'dist:script', 'dev:serve'], function (cb) {
gutil.log('Info :', gutil.colors.green('Build complete!'));
gutil.log('Info :', gutil.colors.green('Opening browser on http://localhost:3000/'));
cb(null)
});
})();