forked from mrvautin/expressCart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (92 loc) · 2.33 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
const { src, dest, series, watch } = require('gulp');
const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
const less = require('gulp-less');
const colors = require('colors');
const cleanCSS = require('gulp-clean-css');
const minify = require('gulp-minify');
const rename = require('gulp-rename');
const nodemonOptions = {
script: 'app.js',
ext: 'js json',
env: { NODE_ENV: 'development' },
verbose: false,
ignore: [],
watch: ['lib/*', 'config/*', 'routes/*', 'app.js']
};
function lessCss(){
return gulp.src('public/stylesheets/less/**/*.less')
.pipe(less({
paths: [
'public/stylesheets/less'
]
}))
.pipe(rename({
dirname: 'public/stylesheets',
extname: '.css'
}))
.pipe(gulp.dest('./'));
};
function compressJS(){
return src([
'public/javascripts/*.js',
'!public/javascripts/*.min.js'
])
.pipe(minify({
ext: {
src: '.js',
min: '.min.js'
}
}))
.pipe(dest('public/javascripts'));
};
function compressCss(){
return src([
'public/stylesheets/*.css',
'!public/stylesheets/*.min.css'
])
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(rename({
dirname: 'public/stylesheets',
extname: '.min.css'
}))
.pipe(dest('./'));
};
function compressThemeCss(){
return src([
'views/themes/**/*.css',
'!views/themes/**/*.min.css'
])
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(rename({
extname: '.min.css'
}))
.pipe(dest('views/themes/'));
};
function compressThemeJS(){
return src([
'views/themes/**/*.js',
'!views/themes/**/*.min.js'
])
.pipe(minify({
ext: {
src: '.js',
min: '.min.js'
}
}))
.pipe(dest('views/themes/'));
};
// run the tasks
gulp.task('default', series(lessCss, compressJS, compressCss, compressThemeCss, compressThemeJS));
gulp.task('watch', (done) => {
// Watch LESS files and generate CSS
watch(['public/stylesheets/less/**/*.less'], async () => {
lessCss();
console.log(colors.blue('CSS generation complete'));
});
// run, watch and restart app
nodemon(nodemonOptions)
.once('quit', () => {
done();
});
});