-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
88 lines (75 loc) · 2.01 KB
/
Copy pathgulpfile.js
File metadata and controls
88 lines (75 loc) · 2.01 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
"use strict";
var gulp = require("gulp"),
sass = require("gulp-sass"),
plumber = require("gulp-plumber"),
postcss = require("gulp-postcss"),
autoprefixer = require("autoprefixer"),
rename = require("gulp-rename"),
imagemin = require("gulp-imagemin"),
combineMq = require("gulp-combine-mq"),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
minifyCss = require('gulp-minify-css'),
rimraf = require('rimraf'),
jade = require('gulp-jade'),
browserSync = require('browser-sync').create();
var scriptList = [
'source/js/common.js'
]
gulp.task("build",["style", "images", "script", "html", "fonts"]);
gulp.task("style", function() {
return gulp.src("source/sass/style.{sass,scss}")
.pipe(plumber())
.pipe(sass({
outputStyle: 'expanded'
})).on('error', sass.logError)
.pipe(postcss([
autoprefixer({browsers: "last 2 versions"})
]))
.pipe(combineMq({
beautify: false
}))
.pipe(minifyCss())
.pipe(rename({
suffix: ".min"
}))
.pipe(gulp.dest("build/css"))
.pipe(browserSync.stream());
});
gulp.task("images", function() {
return gulp.src("source/img/*.{png,jpg,gif,svg}")
.pipe(imagemin())
.pipe(gulp.dest("build/img"));
});
gulp.task('script', function() {
return gulp.src(scriptList)
.pipe(concat('common.js'))
.pipe(gulp.dest('./build/js/'))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./build/js'));
});
gulp.task("html", function() {
return gulp.src("source/jade/*.jade")
.pipe(jade())
.pipe(gulp.dest("build/"));
});
gulp.task("fonts", function() {
return gulp.src("./source/fonts/*.{otf,eot,svg,ttf,woff,woff2}")
.pipe(gulp.dest("build/fonts/"));
});
gulp.task('clean', function (cb) {
return rimraf('build', cb);
});
// Static Server + watching scss/html files
gulp.task('server', ['style'], function() {
browserSync.init({
server: "./",
open: false
});
gulp.watch("sass/**/*.scss", ['style']);
gulp.watch("jade/*.jade"), ["jade"];
gulp.watch("*.html").on('change', browserSync.reload);
});