forked from Clastic/Clastic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
104 lines (90 loc) · 2.99 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
var gulp = require('gulp');
// include plug-ins
var concat = require('gulp-concat'),
stripDebug = require('gulp-strip-debug'),
uglify = require('gulp-uglify'),
autoprefix = require('gulp-autoprefixer'),
minifyCSS = require('gulp-minify-css'),
filesize = require('gulp-filesize'),
rename = require('gulp-rename'),
less = require('gulp-less'),
clean = require('gulp-clean'),
livereload = require('gulp-livereload'),
notify = require("gulp-notify");
var paths = {
'styles': {
'app': [
'web/vendor/multiselect/css/multi-select.css',
'src/Clastic/**/Resources/public/styles/**.less'
],
'main': 'src/Clastic/**/Resources/public/styles/style.less'
},
'scripts': {
'vendor': [
'web/vendor/jquery/dist/jquery.js',
'web/vendor/bootstrap/dist/js/bootstrap.js',
'web/vendor/mousetrap/mousetrap.js',
'web/vendor/quicksearch/dist/jquery.quicksearch.js',
'web/vendor/multiselect/js/jquery.multi-select.js',
'http://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js'
],
'app': [
'src/**/Resources/public/scripts/**.js'
]
},
'templates': 'src/**/*.twig',
'build': 'web/build/'
};
var errorHandler = notify.onError(function (err) {
return "Error: " + err.message;
});
gulp.task('default', ['clean', 'build', 'watch']);
gulp.task('clean', function () {
return gulp.src('build', {read: false})
.pipe(clean());
});
gulp.task('build', ['scripts', 'styles']);
gulp.task('watch', function() {
gulp.watch(paths.scripts.vendor, ['scripts:vendor']);
gulp.watch(paths.scripts.app, ['scripts:app']);
gulp.watch(paths.styles.vendor, ['styles:vendor']);
gulp.watch(paths.styles.app, ['styles:app']);
livereload.listen();
gulp.watch([paths.build + '**', paths.templates])
.on('change', livereload.changed);
});
gulp.task('scripts', ['scripts:vendor', 'scripts:app']);
gulp.task('scripts:vendor', function() {
gulp.src(paths.scripts.vendor)
.pipe(concat('vendor.js'))
//.pipe(stripDebug())
.pipe(uglify())
.pipe(rename('vendor.min.js'))
.pipe(gulp.dest(paths.build))
.pipe(filesize());
});
gulp.task('scripts:app', function() {
gulp.src(paths.scripts.app)
.pipe(concat('app.js'))
//.pipe(stripDebug())
.pipe(uglify())
.on('error', errorHandler)
.pipe(rename('app.min.js'))
.pipe(gulp.dest(paths.build))
.pipe(filesize());
});
// CSS concat, auto-prefix and minify
gulp.task('styles', ['styles:app']);
gulp.task('styles:app', function() {
gulp.src(paths.styles.main)
.pipe(less())
.on('error', errorHandler)
.pipe(concat('app.css'))
.pipe(autoprefix('last 2 versions'))
.pipe(minifyCSS({
keepSpecialComments: 0
}))
.pipe(rename('app.min.css'))
.pipe(gulp.dest(paths.build))
.pipe(filesize());
});