-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
125 lines (97 loc) · 3.14 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
rigger = require('gulp-rigger'),
browserSync = require('browser-sync'),
wait = require('gulp-wait'),
del = require('del'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
listing = require('gulp-listing');
gulp.task('clear', function() {
// Удаляем папку build перед сборкой
del.sync('build');
});
gulp.task('sass', function(){
gulp.src('src/sass/**/*.scss')
.pipe(sourcemaps.init())
// .pipe(wait(300))
.pipe(sass({indentType: 'tab', indentWidth: '1', outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('src/temp'));
// .pipe(browserSync.reload({stream:true}));
});
gulp.task('autoprefixer', function () {
gulp.src('src/temp/**/*.css')
.pipe(postcss( [ autoprefixer() ] ))
.pipe(gulp.dest('build/css'))
.pipe(wait(500))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('browser-sync', function(){
browserSync({
server: {
baseDir: 'build',
index: 'sitemap.html'
},
notify: false
});
});
gulp.task('sitemap', function() {
gulp.src('src/*.html')
.pipe(listing('sitemap.html'))
.pipe(gulp.dest('build/'));
});
gulp.task('html', function() {
gulp.src('src/**/*.html')
.pipe(rigger())
.pipe(gulp.dest('build/'))
.pipe(wait(300))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('js', function() {
gulp.src('src/js/**/*')
.pipe(gulp.dest('build/js'));
});
gulp.task('copy', ['clear', 'sass', 'autoprefixer', 'html', 'js', 'browser-sync', 'sitemap'], function(){
var buildFonts = gulp.src('src/fonts/**/*')
.pipe(gulp.dest('build/fonts'));
var buildImages = gulp.src('src/i/**/*')
.pipe(gulp.dest('build/i'));
var buildUserimg = gulp.src('src/userimg/**/*')
.pipe(gulp.dest('build/userimg'));
var copyHtml = gulp.src('src/*.html')
.pipe(gulp.dest('build'));
var copyJs = gulp.src('src/js/**/*.js')
.pipe(gulp.dest('build/js'));
var copyVideo = gulp.src('src/video/**/*.*')
.pipe(gulp.dest('build/video'));
var copyCSV = gulp.src('src/*.csv')
.pipe(gulp.dest('build'));
var buildHtml = gulp.src('src/**/*.html')
.pipe(rigger())
.pipe(gulp.dest('build/'));
var buildPDF = gulp.src('src/pdf/**')
.pipe(gulp.dest('build/pdf'));
});
gulp.task('default', ['sass', 'autoprefixer', 'html', 'js', 'browser-sync', 'sitemap'], function(){
var buildFonts = gulp.src('src/fonts/**/*')
.pipe(gulp.dest('build/fonts'));
var buildImages = gulp.src('src/i/**/*')
.pipe(gulp.dest('build/i'));
var buildUserimg = gulp.src('src/userimg/**/*')
.pipe(gulp.dest('build/userimg'));
var copyHtml = gulp.src('src/*.html')
.pipe(gulp.dest('build'));
var copyJs = gulp.src('src/js/**/*.js')
.pipe(gulp.dest('build/js'));
var copyCSV = gulp.src('src/*.csv')
.pipe(gulp.dest('build'));
var buildHtml = gulp.src('src/**/*.html')
.pipe(rigger())
.pipe(gulp.dest('build/'));
gulp.watch('src/sass/**/*.scss', ['sass']);
gulp.watch('src/temp/**/*.css', ['autoprefixer']);
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/js/**/*.js', ['js']).on('change', browserSync.reload);
});