forked from dropways/deskapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
152 lines (141 loc) · 5.28 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
var autoprefixer, browserSync, concat, config, gulp, imagemin, minify, path, plumber, rename, sass, streamqueue, uglify,changed;
gulp = require('gulp');
sass = require('gulp-sass');
plumber = require('gulp-plumber');
rename = require('gulp-rename');
autoprefixer = require('gulp-autoprefixer');
concat = require('gulp-concat');
uglify = require('gulp-uglify');
imagemin = require('gulp-imagemin');
minify = require('gulp-clean-css');
streamqueue = require('streamqueue');
browserSync = require('browser-sync');
changed = require('gulp-changed');
config = {
srcDir: './src/'
};
var path = {
styles: [
config.srcDir + 'styles/theme.css',
config.srcDir + 'plugins/bootstrap-4.0.0/dist/css/bootstrap.css',
config.srcDir + 'plugins/malihu-custom-scrollbar-plugin-master/jquery.mCustomScrollbar.css',
config.srcDir + 'plugins/bootstrap-wysihtml5-master/src/bootstrap-wysihtml5.css',
config.srcDir + 'fonts/font-awesome/css/font-awesome.css',
config.srcDir + 'fonts/foundation-icons/foundation-icons.css',
config.srcDir + 'fonts/ionicons-master/css/ionicons.css',
config.srcDir + 'fonts/themify-icons/themify-icons.css',
config.srcDir + 'plugins/air-datepicker/dist/css/datepicker.css',
config.srcDir + 'plugins/timedropper/timedropper.css',
config.srcDir + 'plugins/highlight.js/src/styles/solarized-dark.css',
config.srcDir + 'plugins/select2/dist/css/select2.css',
config.srcDir + 'plugins/bootstrap-select/dist/css/bootstrap-select.css',
config.srcDir + 'styles/style.css',
config.srcDir + 'styles/media.css',
],
scripts: [
config.srcDir + 'scripts/jquery.min.js',
config.srcDir + 'scripts/moment.js',
config.srcDir + 'plugins/bootstrap-4.0.0/dist/js/popper.min.js',
config.srcDir + 'plugins/bootstrap-4.0.0/dist/js/bootstrap.js',
config.srcDir + 'plugins/malihu-custom-scrollbar-plugin-master/jquery.mCustomScrollbar.js',
config.srcDir + 'plugins/wysihtml5-master/dist/wysihtml5-0.3.0.js',
config.srcDir + 'plugins/bootstrap-wysihtml5-master/src/bootstrap-wysihtml5.js',
config.srcDir + 'plugins/air-datepicker/dist/js/datepicker.js',
config.srcDir + 'plugins/air-datepicker/dist/js/i18n/datepicker.en.js',
config.srcDir + 'plugins/timedropper/timedropper.js',
config.srcDir + 'plugins/highlight.js/src/highlight.pack.js',
config.srcDir + 'plugins/select2/dist/js/select2.full.js',
config.srcDir + 'plugins/bootstrap-select/dist/js/bootstrap-select.js',
config.srcDir + 'scripts/clipboard.min.js',
config.srcDir + 'scripts/setting.js'
],
fonts: [
config.srcDir + 'fonts/font-awesome/fonts/*.*',
config.srcDir + 'fonts/foundation-icons/*.*',
config.srcDir + 'fonts/ionicons-master/fonts/*.*',
config.srcDir + 'fonts/themify-icons/fonts/*.*',
config.srcDir + 'fonts/**/*.*',
],
images: 'src/images/**/*.*',
php: ['*.php']
};
gulp.task('styles', function() {
var stream;
stream = streamqueue({objectMode: true});
stream.queue(gulp.src(path.styles));
return stream.done()
.pipe(plumber())
.pipe(sass())
.pipe(autoprefixer({browsers: ['last 2 versions'],cascade: false}))
.pipe(concat('style.css'))
.pipe(gulp.dest('vendors/styles/'))
.pipe(minify({keepSpecialComments: 0}))
.pipe(rename({suffix: '.min'}))
.pipe(plumber.stop()).pipe(gulp.dest('vendors/styles/')).pipe(browserSync.reload({stream: true}));
});
gulp.task('scripts', function() {
var stream;
stream = streamqueue({objectMode: true});
stream.queue(gulp.src(path.scripts));
return stream.done()
.pipe(plumber())
.pipe(concat('script.js'))
.pipe(gulp.dest('vendors/scripts/')).pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(plumber.stop())
.pipe(gulp.dest('vendors/scripts/'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('images', function() {
var stream;
stream = streamqueue({objectMode: true});
stream.queue(gulp.src(path.images));
return stream.done()
.pipe(changed('vendors/images/'))
.pipe(imagemin({optimizationLevel: 3,progressive: true,interlaced: true}))
.pipe(gulp.dest('vendors/images/'));
});
gulp.task('php', function() {
var stream;
stream = streamqueue({objectMode: true});
stream.queue(gulp.src(path.php));
return stream.done()
.pipe(browserSync.reload({stream: true}));
});
gulp.task('fonts', function() {
var stream;
stream = streamqueue({objectMode: true});
stream.queue(gulp.src(path.fonts));
return stream.done()
.pipe(gulp.dest('vendors/fonts/'));
});
gulp.task('connect-sync', ['styles', 'scripts', 'php'], function() {
browserSync.init({
proxy: 'localhost/deskapp',
open: true,
reloadDelay: 50,
watchOptions: {
debounceDelay: 50
}
});
gulp.watch(['src/styles/**/**'], ['styles']);
gulp.watch(['src/scripts/**/**'], ['scripts']);
gulp.watch(path.php, ['php']);
return gulp.watch(['*', 'vendors/**/**'], function(file) {
if (file.type === "changed") {
return browserSync.reload(file.path);
}
});
});
gulp.task('watch', function(){
gulp.watch("src/styles/**/*.*", ['styles']);
gulp.watch("src/fonts/**/*", ['fonts']);
gulp.watch("src/scripts/**/*.js", ['scripts']);
//gulp.watch(path.images, ['images']);
});
gulp.task('default', ['styles', 'fonts', 'scripts', 'connect-sync'], function(){
gulp.watch("src/styles/**/*.*", ['styles']);
gulp.watch("src/fonts/**/*", ['fonts']);
gulp.watch("src/scripts/**/*.js", ['scripts']);
//gulp.watch(path.images, ['images']);
});