-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
94 lines (82 loc) · 3.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
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var cssnano = require('gulp-cssnano');
var filter = require('gulp-filter');
var newer = require('gulp-newer');
var notify = require('gulp-notify');
var sass = require('gulp-sass');
var sassGlob = require('gulp-sass-glob');
var sassLint = require('gulp-sass-lint');
var uglify = require('gulp-uglify');
var browserSync = require('browser-sync').create();
var paths = {
appFiles: [
'app/config/*.yml',
'app/Resources/**/*.{md,php,twig,yml}'
],
proxy: 'localhost:8000',
serveDir: '/',
scriptSrc: 'app/Resources/js/**/*.js',
scriptDest: 'web/js',
styleSrc: 'app/Resources/scss/**/*.scss',
styleDest: 'web/css',
fontsSrc: [
'node_modules/font-awesome/fonts/**/*.{ttf,woff,woff2}',
'node_modules/open-sans-fontface/fonts/Bold/**/*.{ttf,woff,woff2}',
'node_modules/open-sans-fontface/fonts/BoldItalic/**/*.{ttf,woff,woff2}',
'node_modules/open-sans-fontface/fonts/Italic/**/*.{ttf,woff,woff2}',
'node_modules/open-sans-fontface/fonts/Regular/**/*.{ttf,woff,woff2}',
],
fontsDest: 'web/fonts',
vendorScriptSrc: [
'node_modules/jquery/dist/jquery.min.js',
'node_modules/jquery-lazyload/jquery.lazyload.js',
'node_modules/jquery-mousewheel/jquery.mousewheel.js',
'node_modules/flot/jquery.flot.js',
'node_modules/flot/jquery.flot.selection.js',
'node_modules/leaflet/dist/leaflet.js',
'node_modules/leaflet-iiif/leaflet-iiif.js',
'node_modules/select2/dist/js/select2.min.js',
],
vendorScriptDest: 'web/js',
};
gulp.task('assets', function () {
gulp.src(paths.fontsSrc)
.pipe(gulp.dest(paths.fontsDest));
gulp.src(paths.vendorScriptSrc)
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.vendorScriptDest));
});
gulp.task('scripts', function () {
gulp.src(paths.scriptSrc)
.pipe(newer(paths.scriptDest + '/*.js'))
.pipe(filter(paths.scriptSrc))
.pipe(concat('script.js'))
.pipe(uglify())
.on('error', notify.onError({title: 'Uglify Error', message: '<%=error%>'}))
.pipe(gulp.dest(paths.scriptDest))
.pipe(browserSync.stream());
});
gulp.task('styles', function () {
gulp.src(paths.styleSrc)
.pipe(sassLint())
.pipe(newer(paths.styleDest + '/*.css'))
.pipe(filter(paths.styleSrc))
.pipe(sassGlob())
.pipe(sass())
.on('error', notify.onError({title: 'Sass Error', message: '<%=error%>'}))
.pipe(cssnano())
.pipe(autoprefixer())
.pipe(gulp.dest(paths.styleDest))
.pipe(browserSync.stream());
});
gulp.task('compile', ['assets', 'scripts', 'styles']);
gulp.task('default', ['assets', 'scripts', 'styles'], function () {
browserSync.init({open: false, proxy: paths.proxy});
gulp.watch(paths.appFiles).on('change', browserSync.reload);
gulp.watch(paths.assetsSrc, ['assets']);
gulp.watch(paths.scriptSrc, ['scripts']);
gulp.watch(paths.styleSrc, ['styles']);
});