-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
115 lines (102 loc) · 3.18 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
108
109
110
111
112
113
114
115
'use strict';
var basePaths = {
src: 'frontdev/',
dist: 'src/assets/'
};
var gulp = require('gulp'),
watch = require('gulp-watch'),
browserSync = require("browser-sync"),
rigger = require('gulp-rigger'),
less = require('gulp-less'),
reload = browserSync.reload,
rimraf = require('gulp-rimraf');//,
//cleanCSS = require('gulp-clean-css'),
//htmlmin = require('gulp-htmlmin');
var path = {
bower: {
jquery: ['./bower_components/jquery/dist/jquery.min.js','./frontdev/js/vendor/jquery/jquery.min.js']
},
build: { // compiled files
partialsJs: basePaths.dist + 'js/',
js: basePaths.dist + 'js/',
css: basePaths.dist + 'css/',
fonts: basePaths.dist + 'css/fonts/',
img: basePaths.dist + 'img/',
assets: basePaths.dist + 'assets/'
},
dev: { // development files
partialsJs: [basePaths.src + 'js/**/**/*.js', basePaths.src + 'js/**/**/*.json'],
js: basePaths.src + 'js/app.js',
less: basePaths.src + '/less/styles.less',
fonts: basePaths.src + 'less/fonts/**/*.*',
img: basePaths.src + 'img/**/*.*',
assets: basePaths.src + 'assets/**/*.*'
},
watch: { // watching files
js: basePaths.src + 'js/**/*.js',
less: basePaths.src + 'less/**/*.less',
fonts: basePaths.src + 'less/fonts/**/*.*',
img: basePaths.src + 'img/**/*.*',
assets: basePaths.src + 'assets/**/*.*'
},
clean: [basePaths.src + 'css']
};
gulp.task('style:build', function () {
return gulp.src(path.dev.less)
.pipe(less())
//.pipe(cleanCSS())
.pipe(gulp.dest(path.build.css))
.pipe(reload({stream: true}));
});
gulp.task('fonts:build', function () {
return gulp.src(path.dev.fonts)
.pipe(gulp.dest(path.build.fonts))
.pipe(reload({stream: true}));
});
gulp.task('js:build', function () {
gulp.src(path.dev.partialsJs).pipe(gulp.dest(path.build.partialsJs));
return gulp.src(path.dev.js)
.pipe(gulp.dest(path.build.js))
.pipe(reload({stream: true}));
});
gulp.task('img:build', function () {
return gulp.src(path.dev.img)
.pipe(gulp.dest(path.build.img))
.pipe(reload({stream: true}));
});
gulp.task('assets:build', function () {
return gulp.src(path.dev.assets)
.pipe(gulp.dest(path.build.assets))
.pipe(reload({stream: true}));
});
gulp.task('build', [
'style:build',
'fonts:build',
'js:build',
'img:build',
'assets:build'
]);
gulp.task('watch', function(){
watch([path.watch.html], function(event, cb) {
gulp.start('html:build');
});
watch([path.watch.css], function(event, cb) {
gulp.start('style:build');
});
watch([path.watch.fonts], function(event, cb) {
gulp.start('fonts:build');
});
watch([path.watch.js], function(event, cb) {
gulp.start('js:build');
});
watch([path.watch.img], function(event, cb) {
gulp.start('img:build');
});
watch([path.watch.assets], function(event, cb) {
gulp.start('assets:build');
});
});
gulp.task('clean', function (cb) {
rimraf(path.clean, cb);
});
gulp.task('default', ['build', 'watch']);