-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (70 loc) · 2.27 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
const gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
del = require('del'),
autoprefixer = require('gulp-autoprefixer'),
babel = require('gulp-babel');
gulp.task('clean', async function(){
del.sync('dist')
});
gulp.task('css', function(){
return gulp.src([
'node_modules/normalize.css/normalize.css'
])
.pipe(concat('_libs.scss'))
.pipe(gulp.dest('src/scss'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('scss', function(){
return gulp.src('src/scss/**/*.scss')
.pipe(sass({outputStyle: 'expanded'}))
.pipe(autoprefixer({
overrideBrowserslist: ['last 8 versions'],
cascade: false
}))
// .pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('html', function(){
return gulp.src('dist/**/*.html')
.pipe(browserSync.reload({stream: true}))
});
gulp.task('js', function(){
return gulp.src('src/js/**/*.js')
// .pipe(concat('main.js'))
.pipe(babel({
presets: ['@babel/preset-env']
}))
// .pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "src/"
}
});
});
gulp.task('export', async function(){
const buildHtml = gulp.src('src/**/*.html')
.pipe(gulp.dest('dist'));
const buildCss = gulp.src('src/css/**/*.css')
.pipe(gulp.dest('dist/css'));
const buildJs = gulp.src('src/js/**/*.js')
.pipe(gulp.dest('dist/js'));
const buildImg = gulp.src('src/img/**/*.*')
.pipe(gulp.dest('dist/img'));
const buildFonts = gulp.src('src/fonts/**/*.*')
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('watch', function(){
gulp.watch('src/scss/**/*.scss', gulp.parallel('scss'));
gulp.watch('src/**/*.html', gulp.parallel('html'));
gulp.watch('src/js/**/*.js', gulp.parallel('js'));
});
gulp.task('build', gulp.series('clean', 'export'));
gulp.task('default', gulp.parallel('css', 'scss', 'js', 'browser-sync', 'watch'));