This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
98 lines (89 loc) · 2.52 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
var gulp = require('gulp');
var del = require('del');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var concatCss = require('gulp-concat-css');
var plumber = require("gulp-plumber");
var ghPages = require('gulp-gh-pages');
//Пути
const paths = {
styles: {
src: "src/styles/main.scss",
watch: "src/styles/**/*.scss",
dest: "dist/styles/"
},
stylesNlz: {
src: "src/styles/layout/normalize.css",
dest: "dist/styles/normalize/"
},
scripts: {
src: "src/scripts/main.js",
watch: "src/scripts/modules/*.js",
dest: "dist/scripts/"
},
html: {
src: "src/*.html",
watch: "src/*.html",
dest: "dist/"
},
images: {
src: "src/images/**/*.*",
dest: "dist/images/"
},
fonts: {
src: "src/fonts/*.*",
dest: "dist/fonts/"
}
};
//Удаление папки dist
gulp.task("clean", () => {
return del("dist");
});
//Создание ветки gh-pages и загрузка туда содержимого папки dist
gulp.task("deploy", () => {
return gulp.src("./dist/**/*").pipe(ghPages());
});
//Перенос файлов
gulp.task('html', function() {
return gulp
.src(paths.html.src)
.pipe(plumber())
.pipe(gulp.dest(paths.html.dest));
});
gulp.task('stylesNlz', function() {
return gulp.src(paths.stylesNlz.src).pipe(gulp.dest(paths.stylesNlz.dest));
});
gulp.task('images', function() {
return gulp.src(paths.images.src).pipe(gulp.dest(paths.images.dest));
});
gulp.task('fonts', function() {
return gulp.src(paths.fonts.src).pipe(gulp.dest(paths.fonts.dest));
});
gulp.task('serve', ['sass'], function() {
browserSync.init({
server: "src/"
});
//Слежение
gulp.watch(paths.styles.watch, ['sass']);
gulp.watch(paths.html.watch).on('change', browserSync.reload);
gulp.watch(paths.images.src).on('change', browserSync.reload);
});
//Компилируем scss в css + автопрефиксер
gulp.task('sass', function() {
return gulp
.src(paths.styles.src)
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(concatCss("main.css"))
.pipe(gulp.dest(paths.styles.dest))
.pipe(browserSync.stream());
});
//Запуск сборки
gulp.task('build', ['clean', 'serve','html', 'stylesNlz', 'fonts', 'images']);
//Запуск default
gulp.task('default', ['build']);