This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.babel.js
92 lines (80 loc) · 2.03 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
'use strict';
import browserSync from 'browser-sync';
import del from 'del';
import gulp from 'gulp';
import cleanCSS from 'gulp-clean-css';
import less from 'gulp-less';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
import yargs from 'yargs';
const argv = yargs.option('host', {
default: 'http://localhost'
}).argv;
const paths = {
php: './templates/padraogoverno01/**/*.php',
styles: {
src: './templates/padraogoverno01/less/*.less',
dest: './templates/padraogoverno01/css/'
},
scripts: {
src: [
'./templates/padraogoverno01/js/*.js',
'!./templates/padraogoverno01/js/*.min.js'
],
dest: './templates/padraogoverno01/js/'
}
};
const reload = (done) => {
browserSync.reload();
done();
};
const serve = (done) => {
browserSync.init({
proxy: argv.host,
open: false
});
done();
};
/**
* Limpa a pasta de destino dos css
*/
export const clean = () =>
del([paths.styles.dest, '!./templates/padraogoverno01/css/custom.css']);
/**
* Processa os arquivos LESS e comprime o CSS
*/
export const styles = () => {
return gulp
.src([paths.styles.src, '!./templates/padraogoverno01/less/_*.less'])
.pipe(less())
.pipe(cleanCSS({ compatibility: 'ie7' }))
.pipe(gulp.dest(paths.styles.dest));
};
/**
* Minifica arquivos javascripts
*/
export const scripts = () => {
return gulp
.src(paths.scripts.src)
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest(paths.scripts.dest));
};
/**
* Monitora e processa os arquivos quando alterados.
* Usado para desenvolvimento
*/
const watchFiles = () => {
const watchOptions = { usePolling: true };
gulp.watch(paths.php, watchOptions, reload);
gulp.watch(paths.styles.src, watchOptions, gulp.series(styles, reload));
gulp.watch(paths.scripts.src, watchOptions, gulp.series(scripts, reload));
};
export const dev = gulp.series(
clean,
gulp.parallel(styles, scripts),
serve,
watchFiles
);
export const build = gulp.series(clean, gulp.parallel(styles, scripts));
export default dev;