-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
107 lines (98 loc) · 2.89 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
var fs = require("fs"),
path = require('path'),
serverConf = (fs.existsSync('./config.json')) ? require('./config.json').server : null,
gulp = require("gulp"),
gutil = require('gulp-util'),
notify = require("gulp-notify"),
concat = require("gulp-concat"),
imagemin = require("gulp-imagemin"),
less = require("gulp-less"),
sourcemaps = require('gulp-sourcemaps'),
cleanCSS = require('gulp-clean-css'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create();
var config = {
paths: {
images: {
src: ["img/**/*.jpg", "img/**/*.jpeg", "img/**/*.png"],
dest: "img"
},
less: {
path: "less/**/*.less",
src: {
dev: [
"less/iabootstrap-default.less",
"less/iabootstrap-bedroom.less",
"less/iabootstrap-carrot.less",
"less/iabootstrap-roseus.less",
"less/iabootstrap-sky.less"
],
prod: [
"less/iabootstrap-default.less",
"less/iabootstrap-bedroom.less",
"less/iabootstrap-carrot.less",
"less/iabootstrap-roseus.less",
"less/iabootstrap-sky.less",
"less/ckeditor.less"
]
},
dest: "css"
}
}
};
gulp.task("images", function() {
return gulp.src(config.paths.images.src)
.pipe(imagemin({
progressive: true,
interlaced: true
}))
.pipe(gulp.dest(config.paths.images.dest));
});
gulp.task("less-dev", function(){
return gulp.src(config.paths.less.src.dev)
.pipe(sourcemaps.init())
.pipe(less().on('error', function(err) {
gutil.log(err);
this.emit('end');
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.paths.less.dest))
.pipe(notify({
sound: true,
title: "Yay! LESS compiled! =)",
message: "File: <%= file.relative %>",
icon: path.join(__dirname, "docs/img/icon.png")
}))
.pipe(browserSync.stream());
});
gulp.task("less", function() {
return gulp.src(config.paths.less.src.prod)
.pipe(less().on('error', function(err) {
gutil.log(err);
this.emit('end');
}))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(cleanCSS({
advanced: false,
processImport: false
}))
.pipe(gulp.dest(config.paths.less.dest));
});
gulp.task('browser-sync', function() {
if (serverConf !== null) {
browserSync.init(serverConf);
} else {
console.log('\x1b[31m', '***\nBrowserSync config not specified.\nRunning without livereload...\n***' ,'\x1b[0m');
}
});
gulp.task("build", ["less", "images"]);
gulp.task("watch", function() {
gulp.watch(config.paths.less.path, ["less-dev"]);
});
gulp.task("dev", ["less-dev", "images", "browser-sync", "watch"]);
gulp.task("default", function() {
console.log('Silence is gold');
});