-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
65 lines (57 loc) · 1.84 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
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
const minifyCSS = require('gulp-csso');
const minifyImg = require('gulp-imagemin');
const minifyJS = require('gulp-uglify');
const concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
const del = require('del');
gulp.task('browser-sync', () => {
browserSync.init({
server: {
baseDir: "dist"
}
});
});
gulp.task('css', () => {
return gulp.src('src/scss/**/*.scss')
.pipe(sass({
outputStyle: 'nested',
precision: 10,
includePaths: ['.']
}).on('error', sass.logError))
.pipe(minifyCSS())
.pipe(autoprefixer())
.pipe(concat('app.min.css'))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.stream());
});
gulp.task('js', () => {
return gulp.src('src/js/**/*.js')
.pipe(concat('app.min.js'))
.pipe(minifyJS())
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.stream());
});
gulp.task('html', () => {
gulp.src('src/**/*.html')
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
});
gulp.task('img', () => {
/*
Eğer resimleri minify etmek isterseniz yorum satırını kaldırabilirsiniz.
*/
gulp.src('src/img/**/*')
// .pipe(minifyImg())
.pipe(gulp.dest('dist/img'));
});
gulp.task('delete', () => del(['dist/css', 'dist/js', 'dist/img', 'dist/**/*.html']));
gulp.task('watch', () => {
gulp.watch("src/scss/**/*.scss", gulp.task('css'));
gulp.watch("src/js/**/*.js", gulp.task('js'));
gulp.watch("src/img/**/*.img", gulp.task('img'));
gulp.watch("src/**/*.html", gulp.task('html'));
});
gulp.task('default', gulp.series('delete', gulp.parallel('html', 'css', 'js', 'img', 'browser-sync', 'watch')));