-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulp.js
105 lines (89 loc) · 2.39 KB
/
gulp.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
const gulp = require("gulp"),
minify = require("gulp-minify"),
sass = require("gulp-sass"),
connect = require("gulp-connect-php"),
browserSync = require("browser-sync"),
cleanCSS = require("gulp-clean-css"),
sourcemaps = require("gulp-sourcemaps"),
rename = require("gulp-rename"),
plumber = require("gulp-plumber");
gulp.task("browser-reload", function() {
return browserSync.reload();
});
gulp.task("build-images", function() {
return gulp
.src("img/**/*.*")
.pipe(gulp.dest("dist/img"));
});
gulp.task("build-css-gifs", function() {
return gulp
.src("css/*.gif")
.pipe(gulp.dest("dist/css"));
});
gulp.task("build-js", function() {
return gulp
.src("js/*.js")
.pipe(plumber())
.pipe(
minify({
ext: {
src: "-debug.js",
min: ".min.js"
},
ignoreFiles: ["*.min.js"],
noSource: true
})
)
.pipe(gulp.dest("dist/js"));
});
gulp.task("sass", function() {
return gulp
.src("scss/**/*.scss")
.pipe(plumber())
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest("./css/"));
});
gulp.task("build-sass", function() {
return gulp
.src("scss/style.scss")
.pipe(plumber())
.pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
.pipe(sourcemaps.init())
.pipe(cleanCSS({level: {1: {specialComments: 0}}}))
.pipe(sourcemaps.write())
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("dist/css"));
});
gulp.task("build-fonts", function() {
return gulp
.src("fonts/*.*")
.pipe(gulp.dest("dist/fonts"));
});
gulp.task("build-fonts-css", function() {
return gulp
.src("fonts/*.*")
.pipe(gulp.dest("dist/css/fonts"));
});
gulp.task('run-connect-php', function() {
connect.server({
port: 8010,
keepalive: true});
});
gulp.task('browser-sync',['run-connect-php'], function() {
browserSync({
proxy: '127.0.0.1:8010',
port: 8010,
open: true,
notify: false
});
gulp.watch("**/*.php").on("change", function() {
browserSync.reload();
});
});
gulp.task("watch-sass", function() {
gulp.watch("scss/**/*.scss", ["sass"]);
gulp.watch("css/style.css", ["browser-reload"]);
});
gulp.task("watch", ["browser-sync", "watch-sass"]);
gulp.task("default", ["watch"]);
gulp.task("build", ["build-sass", "build-js", "build-images", "build-fonts", "build-fonts-css", "build-css-gifs"]);