-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
100 lines (80 loc) · 2.57 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
let gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
del = require('del'),
autoprefixer= require('gulp-autoprefixer'),
csscomb = require('gulp-csscomb');
gulp.task('clean',async function () {
del.sync('dist')
});
gulp.task('scss',function () {
return gulp.src('app/scss/**/*.scss')
.pipe(sass({outputStyle:'compressed'}))
.pipe(autoprefixer({
overrideBrowserslist:['last 8 versions']
}))
.pipe(rename({suffix:'.min'}))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream:true}))
});
gulp.task('stylus', function () {
return gulp.src('app/scss/**/*.scss')
.pipe(csscomb())
.pipe(gulp.dest('app/scss'))
.pipe(browserSync.reload({stream:true}))
});
gulp.task('css',function () {
return gulp.src([
'node_modules/normalize.css/normalize.css',
'node_modules/slick-carousel/slick/slick.css',
])
.pipe(concat('_libs.scss'))
.pipe(gulp.dest('app/scss'))
.pipe(browserSync.reload({stream:true}))
});
gulp.task('html',function () {
return gulp.src('app/*.html')
.pipe(browserSync.reload({stream:true}))
});
gulp.task('script',function () {
return gulp.src('app/js/*.js')
.pipe(browserSync.reload({stream:true}))
});
gulp.task('js',function () {
return gulp.src([
'node_modules/slick-carousel/slick/slick.js',
])
.pipe(concat('libs.min.js'))
.pipe(uglify())
.pipe(gulp.dest('app/js'))
.pipe(browserSync.reload({stream:true}))
});
gulp.task('browser-sync',function () {
browserSync.init({
server: {
baseDir:'app/'
}
});
});
gulp.task('export', async function () {
let buildHtml = gulp.src('app/**/*.html')
.pipe(gulp.dest('dist'));
let buildCss = gulp.src('app/css/**/*.css')
.pipe(gulp.dest('dist/css'));
let buildJs = gulp.src('app/js/**/*.js')
.pipe(gulp.dest('dist/js'));
let buildFonts = gulp.src('app/fonts/**/*.*')
.pipe(gulp.dest('dist/fonts'));
let buildImg = gulp.src('app/img/**/*.*')
.pipe(gulp.dest('dist/img'));
});
gulp.task('watch', function () {
gulp.watch('app/scss/**/*.scss', gulp.parallel('scss'));
gulp.watch('app/*.html', gulp.parallel('html'));
gulp.watch('app/js/*.js', gulp.parallel('script'));
});
gulp.task('build',gulp.series('clean','export'));
gulp.task('default',gulp.parallel('css','scss','js','browser-sync','watch'));