forked from matjon/cieplo-wlasciwie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
135 lines (116 loc) · 4.59 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
var path = require('path'),
fs = require('fs'),
rs = require('randomstring'),
del = require('del'),
gulp = require('gulp'),
compass = require('gulp-compass'),
uglify = require('gulp-uglify'),
cssmin = require('gulp-cssmin'),
flatten = require('gulp-flatten'),
concat = require('gulp-concat');
gulp.task('version:bump', function(cb){
var path = './app/config/parameters.yml';
fs.readFile(path, 'utf8', function(err, data){
if (err) {
cb();
return;
}
var result = data.replace(/assets_version: [a-zA-Z0-9]+\n/, 'assets_version: ' + rs.generate(16) + "\n");
fs.writeFile(path, result, 'utf8', function(err){
cb();
});
});
});
gulp.task('clean:js', function(){
del.sync(['./web/assets/js/**']);
});
gulp.task('clean:css', function(){
del.sync(['./web/assets/css/**']);
});
gulp.task('clean:fonts', function(){
del.sync(['./web/assets/fonts/**']);
});
gulp.task('clean:images', function(){
del.sync(['./web/assets/images/**']);
});
gulp.task('vendor:css', ['clean:css'], function(){
return gulp.src([
'./bower/bootstrap/dist/css/bootstrap.css',
'./bower/bootstrap-material-design/dist/css/bootstrap-material-design.css',
'./bower/bootstrap-material-design/dist/css/ripples.css',
]).pipe(concat('vendor.css')).pipe(cssmin()).pipe(gulp.dest('./web/assets/css'));
});
gulp.task('vendor:ranking_css', [], function(){
return gulp.src([
'./vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/sass/mopabootstrapbundle.scss',
]).pipe(concat('ranking_vendor.css')).pipe(cssmin()).pipe(gulp.dest('./web/assets/css'));
});
gulp.task('vendor:js', ['clean:js'], function(){
return gulp.src([
'./bower/jquery/dist/jquery.js',
'./bower/raphael/raphael.min.js',
'./bower/bootstrap/dist/js/bootstrap.js',
'./bower/bootstrap-material-design/dist/js/material.js',
'./bower/bootstrap-material-design/dist/js/ripples.js',
'./vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/js/mopabootstrap-collection.js'
]).pipe(concat('vendor.js')).pipe(uglify()).pipe(gulp.dest('./web/assets/js'));
});
gulp.task('vendor:ranking_js', [], function(){
return gulp.src([
'./vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/bootstrap/js/tooltip.js',
'./vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/bootstrap/js/*.js',
'./vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/js/mopabootstrap-collection.js',
'./vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/js/mopabootstrap-subnav.js',
]).pipe(concat('ranking_vendor.js')).pipe(uglify()).pipe(gulp.dest('./web/assets/js'));
});
gulp.task('vendor:fonts', ['clean:fonts'], function(){
return gulp.src([
'./bower/bootstrap/dist/fonts/*'
]).pipe(flatten()).pipe(gulp.dest('./web/assets/fonts'));
});
gulp.task('app:css', ['clean:css'], function(){
return gulp.src('./app/Resources/scss/app.scss').pipe(compass({
project: path.join(__dirname),
logging: true,
css: 'web/assets/css',
sass: 'app/Resources/scss',
font: 'web/assets/fonts',
style: 'compressed',
import_path: [
// Remember to add all paths
]
}));
});
gulp.task('app:js', ['clean:css'], function(){
return gulp.src([
'./app/Resources/js/app.js'
]).pipe(concat('app.js')).pipe(uglify()).pipe(gulp.dest('./web/assets/js'));
});
gulp.task('app:images', ['clean:images'], function(){
return gulp.src([
'./app/Resources/images/*',
'./src/Kraken/WarmBundle/Resources/public/images/*'
]).pipe(flatten()).pipe(gulp.dest('./web/assets/images'));
});
gulp.task('app:ranking_css', [], function(){
return gulp.src('./src/Kraken/RankingBundle/Resources/public/scss/ranking.scss').pipe(compass({
project: path.join(__dirname),
logging: true,
css: 'web/assets/css',
sass: 'src/Kraken/RankingBundle/Resources/public/scss',
font: 'web/assets/fonts',
style: 'compressed',
import_path: [
// Remember to add all paths
]
}));
});
gulp.task('watch', function(){
gulp.watch('./app/Resources/scss/**/*.scss', ['vendor:css', 'app:css', 'version:bump']);
gulp.watch('./app/Resources/js/**/*.js', ['vendor.js', 'app:js', 'version:bump']);
});
gulp.task('clean', ['clean:js', 'clean:css', 'clean:fonts', 'clean:images']);
gulp.task('vendor', ['vendor:js', 'vendor:css', 'vendor:ranking_js', 'vendor:ranking_css', 'vendor:fonts']);
gulp.task('app', ['app:js', 'app:css', 'app:ranking_css', 'app:images']);
gulp.task('build', ['clean', 'vendor', 'app']);
gulp.task('default', ['build', 'version:bump']);