forked from vektorprogrammet/vektorprogrammet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·113 lines (98 loc) · 2.97 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
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: 'www/',
src: 'app/Resources/assets/'
};
gulp.task('stylesProd', function () {
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))
});
gulp.task('scriptsProd', function () {
var dest = path.dist + 'js/';
gulp.src(path.src + 'js/**/*.js')
.pipe(plumber())
.pipe(changed(dest))
.pipe(uglify())
.pipe(gulp.dest(dest))
});
gulp.task('imagesProd', function () {
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))
});
gulp.task('stylesDev', function () {
var dest = path.dist + 'css/';
gulp.src(path.src + 'scss/**/*.scss')
.pipe(plumber())
.pipe(changed(dest))
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest(dest))
});
gulp.task('scriptsDev', function () {
var dest = path.dist + 'js/';
gulp.src(path.src + 'js/**/*.js')
.pipe(plumber())
.pipe(changed(dest))
.pipe(gulp.dest(path.dist + 'js/'))
.pipe(gulp.dest(dest))
});
gulp.task('imagesDev', function () {
var dest = path.dist + 'img/';
gulp.src(path.src + 'img/**/*')
.pipe(plumber())
.pipe(changed(dest))
.pipe(gulp.dest(dest))
});
gulp.task('compressImages', function(){
var dest = 'www/images/';
gulp.src('www/images/**/*')
.pipe(plumber())
.pipe(imagemin({
progressive: false,
interlaced: false,
optimizationLevel: 1
}))
.pipe(gulp.dest(dest))
});
gulp.task('files', function(){
gulp.src(path.src + 'files/*')
.pipe(changed('www/files/'))
.pipe(gulp.dest('www/files/'))
});
gulp.task('libs', function(){
gulp.src(path.src + 'libs/**/*')
.pipe(changed('www/libs/'))
.pipe(gulp.dest('www/libs/'))
});
gulp.task('watch', function () {
gulp.watch(path.src + 'scss/**/*.scss', ['stylesDev']);
gulp.watch(path.src + 'js/**/*.js', ['scriptsDev']);
gulp.watch(path.src + 'images/*', ['imagesDev']);
});
gulp.task('build:prod', ['stylesProd', 'scriptsProd', 'imagesProd', 'files', 'libs']);
gulp.task('build:dev', ['stylesDev', 'scriptsDev', 'imagesDev', 'files', 'libs']);
gulp.task('default', ['build:dev', 'watch']);