This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
110 lines (93 loc) · 3.07 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
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'),
del = require('del'),
livereload = require('gulp-livereload'),
notify = require("gulp-notify"),
clasticNamespace = require('./vendor/clastic/core-bundle/Resources/scripts/Clastic.js');
clasticNamespace();
var paths = {
'styles': {
'app': [
'web/vendor/multiselect/css/multi-select.css',
'vendor/clastic/*/Resources/public/styles/**.less',
'vendor/clastic/*/Resources/public/styles/*/*.less'
],
'main': 'vendor/clastic/*/Resources/public/styles/style.less'
},
'scripts': {
'vendor': [
'vendor/clastic/*/Resources/public/scripts/**.config.js',
'http://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js'
],
'app': [
'vendor/clastic/*/Resources/public/scripts/**.js'
]
},
'templates': 'src/**/*.twig',
'build': 'web/build/'
};
var clastic = new Clastic.Clastic();
var rootDir = __dirname + '/vendor/clastic';
paths = clastic.resolvePaths(paths, rootDir);
var errorHandler = notify.onError(function (err) {
return "Error: " + err.message;
});
gulp.task('default', ['clean', 'build', 'watch']);
gulp.task('clean', function (cb) {
del([
paths.build + '/**'
], cb);
});
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 1 versions'))
.pipe(minifyCSS({
keepSpecialComments: 0
}))
.pipe(rename('app.min.css'))
.pipe(gulp.dest(paths.build))
.pipe(filesize());
});