-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (75 loc) · 2.26 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
const gulp = require("gulp"),
plumber = require('gulp-plumber'),
watch = require('gulp-watch'),
image = require('gulp-image'),
pug = require("gulp-pug"),
sass = require("gulp-sass"),
babel = require("gulp-babel"),
autoprefixer = require("gulp-autoprefixer"),
cleanCSS = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
browserSync = require('browser-sync').create()
gulp.task('images', function(cb) {
gulp.src(['./build/**/*.png','./build/**/*.jpg','./build/**/*.JPG','./build/**/*.gif','./build/**/*.jpeg'])
.pipe(image({
pngquant: true,
optipng: false,
zopflipng: true,
jpegRecompress: false,
mozjpeg: true,
guetzli: false,
gifsicle: true,
svgo: true,
concurrent: 10,
quiet: true
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task("CompilePug",()=>{
gulp.src("./build/pug/**/!(_)*.pug")
.pipe(plumber())
.pipe(pug({
pretty : true
}))
.pipe(gulp.dest("./dist/"));
})
//Definicion de Tareas
gulp.task("CompileSass", ()=>{
gulp.src("./build/sass/**/*.scss")
.pipe(watch("./build/sass/**/*.scss"))
.pipe(plumber())
.pipe(sass({
outputStyle: "expanded"
}))
.pipe(autoprefixer({
versions: ['last 2 browsers']
}))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest("./dist/css"))
.pipe(browserSync.stream())
});
gulp.task("compilejs", () => {
gulp.src(["./build/js/**/*.js"])
.pipe(watch(["./build/js/**/*.js"]))
.pipe(plumber())
.pipe(babel())
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest("./dist/js"))
});
gulp.task("serve",()=>{
browserSync.init({
server: "./dist/",
notify: false,
});
gulp.watch("./dist/*.html").on("change", browserSync.reload)
gulp.watch("./dist/js/*.js", () =>{
browserSync.reload();
});
});
gulp.task("default", ["CompilePug","CompileSass","compilejs"],() => {
gulp.watch("./build/pug/**/*.pug",["CompilePug"])
gulp.start("serve");
});