-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
48 lines (44 loc) · 1.23 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
let gulp = require('gulp')
let sass = require('gulp-sass')
let minify = require('gulp-clean-css')
let browserSync = require('browser-sync').create()
let imagemin = require('gulp-imagemin')
const autoprefixer = require('gulp-autoprefixer')
var htmlmin = require('gulp-htmlmin')
// inicializa servidor web
gulp.task('serve', () => {
browserSync.init({
server: './',
})
// gulp.watch("sass/**/*.sass", ['sass']) // guarda sass como css
// gulp.watch("./app/js/*.js").on('change', browserSync.reload) // recarga cuando guarda js
gulp.watch('./*.html').on('change', browserSync.reload)
gulp.watch('./style/*.css').on('change', browserSync.reload) // minifica html
})
// compila sass a css
gulp.task('sass', () => {
return gulp
.src('sass/**/*.sass')
.pipe(sass())
.pipe(minify())
.pipe(
autoprefixer({
browsers: ['last 10 versions'],
cascade: false,
})
)
.pipe(gulp.dest('./app/css'))
.pipe(browserSync.stream())
})
gulp.task('optimize', () => {
gulp
.src('./style/*')
.pipe(imagemin())
.pipe(gulp.dest('app/img'))
})
gulp.task('minifyHTML', function() {
return gulp
.src('*.html')
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('app'))
})