-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
135 lines (108 loc) · 3.88 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
'use strict';
var gulp = require('gulp');
var watch = require('gulp-watch');
var sync = require('gulp-sync')(gulp);
var sass = require('gulp-sass');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var clean = require('gulp-clean');
var cleanCSS = require('gulp-clean-css');
var filesExist = require('files-exist');
var imagemin = require('gulp-imagemin');
gulp.task('dist-clean', function () {
return gulp.src('static/dist/', {read: false})
.pipe(clean());
});
/** For Develop TASK START **/
gulp.task('jquery', function () {
filesExist(['assets/bower_components/jquery/dist']);
return gulp.src('assets/bower_components/jquery/dist/**')
.pipe(gulp.dest('static/dist/jquery'));
});
gulp.task('bootstrap', function () {
filesExist(['assets/bower_components/bootstrap/dist']);
return gulp.src('assets/bower_components/bootstrap/dist/**')
.pipe(gulp.dest('static/dist/bootstrap'));
});
gulp.task('prefixfree', function () {
filesExist(['assets/bower_components/prefixfree']);
return gulp.src('assets/bower_components/prefixfree/**')
.pipe(gulp.dest('static/dist/prefixfree'));
});
gulp.task('slick', function () {
filesExist(['assets/bower_components/slick-carousel/slick']);
return gulp.src('assets/bower_components/slick-carousel/slick/**')
.pipe(gulp.dest('static/dist/slick'));
});
gulp.task('magnificpopup', function () {
filesExist(['assets/bower_components/magnific-popup/dist']);
return gulp.src('assets/bower_components/magnific-popup/dist/**')
.pipe(gulp.dest('static/dist/magnific-popup'));
});
gulp.task('magiccheck', function () {
filesExist(['assets/bower_components/magic-check']);
return gulp.src('assets/bower_components/magic-check/css/**')
.pipe(gulp.dest('static/dist/magic-check'));
});
gulp.task('jquery-validation', function () {
filesExist(['assets/bower_components/jquery-validation']);
return gulp.src('assets/bower_components/jquery-validation/dist/**')
.pipe(gulp.dest('static/dist/jquery-validation'));
});
gulp.task('jquery-validation-bootstrap-tooltip', function () {
filesExist(['assets/bower_components/jquery-validation-bootstrap-tooltip']);
return gulp.src('assets/bower_components/jquery-validation-bootstrap-tooltip/jquery-validate.bootstrap-tooltip.js')
.pipe(gulp.dest('static/dist/jquery-validation-bootstrap-tooltip'));
});
gulp.task('extra-assets-js', function () {
return gulp.src('assets/js/**')
.pipe(gulp.dest('static/dist/js'));
});
gulp.task('extra-assets-css', function () {
return gulp.src('assets/css/**')
.pipe(cleanCSS({compatibility: 'ie9'}))
.pipe(gulp.dest('static/dist/css'));
});
/** For Develop TASK END **/
gulp.task('uglify', function () {
return gulp.src(['assets/js/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(uglify())
.pipe(gulp.dest('static/dist/js'));
});
gulp.task('sass', function () {
return gulp.src([
'assets/scss/**/*.scss',
'!assets/scss/helper/**/*.scss'
])
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('static/dist/css'));
});
gulp.task('dev', ['jquery', 'bootstrap', 'prefixfree', 'slick', 'magnificpopup', 'magiccheck', 'jquery-validation', 'jquery-validation-bootstrap-tooltip', 'extra-assets-js', 'extra-assets-css']);
gulp.task('font', function () {
return gulp.src('assets/fonts/**')
.pipe(gulp.dest('static/dist/fonts'));
});
gulp.task('image', function() {
return gulp.src('static/images/*')
.pipe(imagemin())
.pipe(gulp.dest('static/images'));
});
gulp.task('build', sync.sync([
'dist-clean',
[
'dev',
'uglify',
'sass',
'font',
'image'
]
]));
gulp.task('build:watch', function () {
gulp.watch('assets/scss/**/*.scss', ['sass']);
gulp.watch('assets/css/*.css', ['extra-assets-css']);
gulp.watch('assets/js/*.js', ['uglify']);
});