-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
114 lines (103 loc) · 4.09 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
var gulp = require('gulp');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var uglifycss = require('gulp-uglifycss');
var less = require('gulp-less');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
var env = process.env.GULP_ENV;
//JAVASCRIPT TASK: write one minified js file out of jquery.js, bootstrap.js and all of my custom js files
gulp.task('js', function () {
var vendorsFiles = [
'bower_components/jquery/dist/jquery.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/jquery-ui/jquery-ui.min.js',
'bower_components/metisMenu/dist/metisMenu.min.js',
'bower_components/datatables/media/js/jquery.dataTables.min.js',
'bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js',
'bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js'
];
var appFiles = [
'src/AppBundle/Resources/public/js/vendors/collection.js',
'app/Resources/public/js/**/*.js',
'src/**/public/js/**/*.js'
];
var files = vendorsFiles.concat(appFiles);
return gulp.src(files)
.pipe(concat('javascript.js'))
.pipe(gulpif(env === 'prod', uglify()))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('web/js'));
});
//CSS TASK: write one minified css file out of bootstrap.less and all of my custom less files
gulp.task('css', function () {
var vendorsFiles = [
'bower_components/bootstrap/dist/css/bootstrap.min.css',
'bower_components/metisMenu/dist/metisMenu.min.css',
'bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css',
'bower_components/datatables-responsive/css/dataTables.responsive.css',
'bower_components/startbootstrap-sb-admin-2/dist/css/sb-admin-2.css',
'bower_components/font-awesome/css/font-awesome.min.css',
'bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css'
];
var appFiles = [
'app/Resources/public/less/**/*.less',
'src/**/public/less/**/*.less'
];
var files = vendorsFiles.concat(appFiles);
return gulp.src(files)
.pipe(gulpif(/[.]less/, less()))
.pipe(concat('styles.css'))
.pipe(gulpif(env === 'prod', uglifycss()))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('web/css'));
});
//IMAGE TASK: Just pipe images from project folder to public web folder
gulp.task('img', function () {
var vendorsFiles = [
'bower_components/**/*.png',
'bower_components/**/*.jpg'
];
var appFiles = [
'app/Resources/public/images/*',
'src/**/public/images/*'
];
var files = vendorsFiles.concat(appFiles);
return gulp.src(files)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('web/images'));
});
gulp.task('fonts', function () {
var vendorsFiles = [
'bower_components/**/*.otf',
'bower_components/**/*.eot',
'bower_components/**/*.svg',
'bower_components/**/*.ttf',
'bower_components/**/*.woff',
'bower_components/**/*.woff2'
];
var appFiles = [
'app/Resources/public/fonts/*',
'src/**/public/fonts/*'
];
var files = vendorsFiles.concat(appFiles);
gulp.src(files)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('web/fonts'));
// Special treatment for font-awesome
gulp.src('bower_components/font-awesome/fonts/**.*')
.pipe(gulp.dest('./web/fonts'));
// Special treatment for bootstrap
return gulp.src('bower_components/bootstrap/dist/fonts/**.*')
.pipe(gulp.dest('./web/fonts'));
});
gulp.task('watch', function () {
livereload.listen();
gulp.watch('src/AppBundle/Resources/public/less/*.less', ['css']);
return gulp.watch('src/**/*.js', ['js']);
});
//define executable tasks when running "gulp" command
gulp.task('default', ['js', 'css', 'fonts', 'img']);
gulp.task('sentinel', ['js', 'css', 'fonts', 'img', 'watch']);
gulp.task('build', ['js', 'css', 'fonts', 'img']);