-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
135 lines (124 loc) · 3.15 KB
/
gulpfile.babel.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
const gulp = require('gulp'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
notifier = require('node-notifier');
gulp.task('minifyCSS', () => {
let isSuccess = true;
return gulp
.src('./assets/css/sass-project/main.scss')
.pipe(concat('style.css'))
.pipe(sass({outputStyle: 'compressed'}).on('error', (e) => {
isSuccess = false;
console.log(e);
notifier.notify({
title: 'Error detected',
message: 'An error has occurred with the CSS :(',
type: 'error',
sound: true
});
}))
.pipe(gulp.dest('./assets/css'))
.on('end', () => {
if (isSuccess) {
notifier.notify({
title: 'Change detected',
message: 'The CSS has been compiled successfully! :)',
type: 'info',
sound: true
});
}
});
});
gulp.task('minifyLibrariesJS', () => {
let isSuccess = true;
return gulp
.src([
'./assets/js/jquery-3.2.1.min.js',
'./assets/js/jquery.anchor.js',
'./assets/js/materialize.min.js',
'./assets/js/scrollspy.min.js',
'./assets/js/Chart.min.js',
])
.pipe(babel({
presets: [
'es2015'
]
}))
.pipe(concat('libraries.min.js'))
.pipe(uglify().on('error', (e) => {
isSuccess = false;
console.log(e);
notifier.notify({
title: 'Error detected',
message: 'An error has occurred with the LibrariesJS :(',
type: 'error',
sound: true
});
}))
.pipe(gulp.dest('./assets/js'))
.on('end', () => {
if (isSuccess) {
notifier.notify({
title: 'Change detected',
message: 'The LibrariesJS has been compiled successfully! :)',
type: 'info',
sound: true
});
}
});
});
gulp.task('minifyAppJS', () => {
let isSuccess = true;
return gulp
.src('./assets/js/app.js')
.pipe(concat('app.min.js'))
.pipe(babel({
presets: [
'es2015'
]
}))
.pipe(uglify().on('error', (e) => {
isSuccess = false;
console.log(e);
notifier.notify({
title: 'Error detected',
message: 'An error has occurred with the AppJS :(',
type: 'error',
sound: true
});
}))
.pipe(gulp.dest('./assets/js'))
.on('end', () => {
if (isSuccess) {
notifier.notify({
title: 'Change detected',
message: 'The AppJS has been compiled successfully! :)',
type: 'info',
sound: true
});
}
});
});
gulp.task('default', [
'minifyCSS',
'minifyLibrariesJS',
'minifyAppJS'
]);
gulp.task('watch', () => {
notifier.notify({
title: 'Gulp',
message: 'Watching changes...',
type: 'info'
});
gulp.watch('./assets/css/sass-project/main.scss', ['minifyCSS'])
gulp.watch([
'./assets/js/jquery-3.2.1.min.js',
'./assets/js/jquery.anchor.js',
'./assets/js/materialize.min.js',
'./assets/js/scrollspy.min.js',
'./assets/js/Chart.min.js',
], ['minifyLibrariesJS']);
gulp.watch('./assets/js/app.js', ['minifyAppJS'])
});