This repository was archived by the owner on Feb 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
118 lines (116 loc) · 2.99 KB
/
Copy pathgulpfile.js
File metadata and controls
118 lines (116 loc) · 2.99 KB
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
'use strict';
const gulp = require('gulp'),
sass = require('gulp-sass'),
rigger = require('gulp-rigger'),
watch = require('gulp-watch'),
notify = require("gulp-notify"),
browserSync = require('browser-sync').create(),
image = require('gulp-image'),
htmlmin = require('gulp-htmlmin'),
cleanCSS = require('gulp-clean-css'),
minify = require('gulp-minify');
var path = {
build: {
html: 'build/',
js: 'build/js/',
css: 'build/css/',
img: 'build/img/',
fonts: 'build/fonts/'
},
src: {
html: 'src/*.html',
js: 'src/js/**/*.js',
style: 'src/css/*.scss',
css: 'src/css/**/*.css',
img: 'src/img/**/*.*',
fonts: 'src/fonts/**/*.*'
},
watch: {
html: 'src/**/*.html',
js: 'src/js/**/*.js',
style: 'src/css/**/*.scss',
css: 'src/css/**/*.css',
img: 'src/img/**/*.*',
fonts: 'src/fonts/**/*.*'
},
};
function html() {
gulp.src(path.src.html)
.pipe(rigger())
.pipe(browserSync.stream())
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest(path.build.html));
}
function scss() {
gulp.src(path.src.style)
.pipe(sass().on( 'error', notify.onError(
{
message: "<%= error.message %>",
title : "Sass Error!"
} ) ))
.pipe(browserSync.stream())
.pipe(rigger())
.pipe(cleanCSS())
.pipe(gulp.dest(path.build.css));
}
function css() {
gulp.src(path.src.css)
.pipe(browserSync.stream())
.pipe(rigger())
.pipe(cleanCSS())
.pipe(gulp.dest(path.build.css));
}
function img() {
gulp.src(path.src.img)
.pipe(image())
.pipe(browserSync.stream())
.pipe(gulp.dest(path.build.img));
}
function fnt() {
gulp.src(path.src.fonts)
.pipe(gulp.dest(path.build.fonts));
}
function js() {
gulp.src(path.src.js)
.pipe(browserSync.stream())
.pipe(rigger())
.pipe(minify())
.pipe(gulp.dest(path.build.js))
.on( 'error', notify.onError(
{
message: "<%= error.message %>",
title : "Sass Error!"
} ) );
}
gulp.task('default', function(){
browserSync.init({
server: {
baseDir: "./build"
},
tunnel: true,
host: 'localhost',
port: 9000,
logPrefix: "Frontend_Devil"
});
watch([path.watch.html], function(event, cb) {
html();
}).on('change', browserSync.reload);
watch([path.watch.style], function(event, cb) {
scss();
}).on('change', browserSync.reload);
watch([path.watch.css], function(event, cb) {
css();
}).on('change', browserSync.reload);
watch([path.watch.js], function(event, cb) {
js();
}).on('change', browserSync.reload);
watch([path.watch.img], function(event, cb) {
img();
});
watch([path.watch.fonts], function(event, cb) {
fnt();
});
});
gulp.task('prod', function(){
html();scss();css();js();img();fnt();
});