-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
125 lines (113 loc) · 3.43 KB
/
Copy pathgulpfile.js
File metadata and controls
125 lines (113 loc) · 3.43 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* Gulp configuration file
*
* @package java-goverment
* @since 0.0.1
* @author Rizal Fauzie <fauzie@idjavahost.com>
*/
/**
* === RESOURCES
* - Color Picker : https://farbelous.io/bootstrap-colorpicker/v2/
* - Checkbox Toggle : http://www.bootstraptoggle.com/
* - File Uploader : https://danielmg.org/demo/java-script/uploader
* - Slider : https://github.com/seiyria/bootstrap-slider
* - Sortable : https://github.com/RubaXa/Sortable
*/
var dir_node = './node_modules',
dir_pub = './views/assets'
;
var gulp = require('gulp'),
del = require('del'),
uglify = require('gulp-uglify'),
autoprefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
cleanCSS = require('gulp-clean-css'),
strip = require('gulp-strip-comments'),
concat = require('gulp-concat'),
watch = require('gulp-watch')
;
var config = {
// Autoprefixer options
autoprefixer: {
browsers: [
'Chrome >= 45',
'Firefox ESR',
'Edge >= 12',
'Explorer >= 9',
'iOS >= 9',
'Safari >= 9'
]
},
uglify: {
src: [
dir_node + '/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js',
dir_node + '/bootstrap-toggle/js/bootstrap-toggle.js',
dir_node + '/dm-file-uploader/src/js/jquery.dm-uploader.js',
dir_node + '/bootstrap-slider/dist/bootstrap-slider.js',
dir_node + '/sortablejs/Sortable.js',
dir_pub + '/helper.js',
dir_pub + '/script.js'
],
options: {
ie8: true,
warnings: false
},
base: dir_pub,
name: 'script.min.js'
},
css: {
src: [
dir_node + '/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css',
dir_node + '/select2-bootstrap-theme/dist/select2-bootstrap.css',
dir_node + '/bootstrap-toggle/css/bootstrap-toggle.css',
dir_node + '/dm-file-uploader/src/css/jquery.dm-uploader.css',
dir_node + '/bootstrap-slider/dist/css/bootstrap-slider.css',
dir_pub + '/style.css'
],
options: {
compatibility: "ie8",
rebaseTo: dir_pub,
level: {1: {specialComments: 0}}
},
base: dir_pub,
name: 'style.min.css'
},
};
// GULP TASKS
gulp.task('clean', function() {
return del([
dir_pub + 'core.min.js',
dir_pub + 'script.min.js',
dir_pub + 'style.min.css'
]);
});
gulp.task('js', function(done) {
gulp.src(config.uglify.src)
.pipe(sourcemaps.init())
.pipe(uglify(config.uglify.options).on('error', function(e){
console.log(e.cause);
}))
.pipe(concat(config.uglify.name),{newLine: ""})
.pipe(strip())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.uglify.base))
.on('end', done);
});
gulp.task('css', function(done) {
gulp.src(config.css.src)
.pipe(sourcemaps.init())
.pipe(autoprefixer(config.autoprefixer))
.pipe(cleanCSS(config.css.options))
.pipe(concat(config.css.name),{newLine: ""})
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.css.base))
.on('end', done);
});
gulp.task('watch', function() {
// Watch javascript file changes
gulp.watch(config.uglify.src, ['js']);
// Watch stylesheet file changes
gulp.watch(config.css.src, ['css']);
});
// All in One
gulp.task('default', ['clean', 'js', 'css', 'watch']);