-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
127 lines (111 loc) · 3.46 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
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
autoprefixer = require('gulp-autoprefixer'),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cssnano = require('gulp-cssnano'),
htmlmin = require('gulp-htmlmin'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
changed = require('gulp-changed');
var path = {
dist: 'web/',
src: 'app/Resources/assets/'
};
function stylesProd(){
var dest = path.dist + 'css/';
gulp.src(path.src + 'scss/**/*.scss')
.pipe(plumber())
.pipe(changed(dest))
.pipe(sass())
.pipe(autoprefixer())
.pipe(cssnano())
.pipe(gulp.dest(dest))
}
function scriptsProd(){
var dest = path.dist + 'js/';
gulp.src(path.src + 'js/**/*.js')
.pipe(plumber())
.pipe(changed(dest))
.pipe(uglify())
.pipe(gulp.dest(dest))
}
function imagesProd(){
var dest = path.dist + 'img/';
gulp.src(path.src + 'img/**/*')
.pipe(plumber())
.pipe(changed(dest))
.pipe(imagemin({
progressive: false,
interlaced: false,
optimizationLevel: 1
}))
.pipe(gulp.dest(dest))
}
function stylesDev(){
var dest = path.dist + 'css/';
return gulp.src(path.src + 'scss/**/*.scss')
.pipe(plumber())
.pipe(changed(dest))
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest(dest))
}
function scriptsDev(){
var dest = path.dist + 'js/';
return gulp.src(path.src + 'js/**/*.js')
.pipe(plumber())
.pipe(changed(dest))
.pipe(gulp.dest(dest))
}
function vendor(){
var ret = true;
ret = ret && gulp.src('node_modules/ckeditor/**/*')
.pipe(gulp.dest('web/js/vendor/ckeditor/'));
ret = ret && gulp.src('node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js')
.pipe(gulp.dest('web/js/'));
ret = ret && gulp.src('node_modules/jquery/dist/jquery.min.js')
.pipe(gulp.dest('web/js/'));
ret = ret && gulp.src('node_modules/bootstrap-sass/assets/fonts/bootstrap/*')
.pipe(gulp.dest('web/fonts/bootstrap'));
ret = ret && gulp.src('node_modules/font-awesome/fonts/*')
.pipe(gulp.dest('web/fonts/'));
return ret;
}
function imagesDev(){
var dest = path.dist + 'img/';
return gulp.src(path.src + 'img/**/*')
.pipe(plumber())
.pipe(changed(dest))
.pipe(gulp.dest(dest))
}
function compressImages(){
var dest = 'web/img/';
return gulp.src('web/img/**/*')
.pipe(plumber())
.pipe(imagemin({
progressive: false,
interlaced: false,
optimizationLevel: 1
}))
.pipe(gulp.dest(dest))
}
function config(){
return gulp.src('app/Resources/config/ckeditor.js')
.pipe(concat('config.js'))
.pipe(gulp.dest('web/bundles/ivoryckeditor/'));
}
function files(){
return gulp.src(path.src + 'files/*')
.pipe(gulp.dest('web/files/'))
}
function watch(){
gulp.watch(path.src + 'scss/**/*.scss', stylesDev);
gulp.watch(path.src + 'js/**/*.js', scriptsDev);
gulp.watch(path.src + 'images/*', imagesDev);
}
gulp.task('build:prod', gulp.parallel(stylesProd, scriptsProd, imagesProd, files, vendor, config));
gulp.task('build:dev', gulp.parallel(stylesDev, scriptsDev, imagesDev, files, vendor, config));
gulp.task('default', gulp.series('build:dev', watch));
exports.watch = watch;