-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
105 lines (94 loc) · 2.97 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
var gulp = require('gulp'),
tasks = require('gulp-load-plugins')(),
rimraf = require('rimraf'),
fs = require('fs'),
open = './open.json',
src = 'app/Resources/assets/',
dist = 'web/';
gulp.task(
'clean',
function (callback) {
rimraf.sync(dist + 'app.css');
rimraf.sync(dist + 'app.js');
rimraf.sync(dist + 'fonts/');
callback();
}
);
gulp.task(
'stylesheets',
function () {
gulp.src(src + 'stylesheets/app.less')
.pipe(tasks.plumber())
.pipe(tasks.less())
.pipe(tasks.autoprefixer())
.pipe(tasks.if(tasks.util.env.dist, tasks.csso()))
.pipe(gulp.dest(dist))
.pipe(tasks.livereload());
}
);
gulp.task(
'fonts',
function () {
gulp.src('node_modules/bootstrap/dist/fonts/*')
.pipe(gulp.dest(dist + 'fonts/'));
}
);
gulp.task(
'scripts',
function () {
// Define environment for React according to build mode
tasks.env({ vars: { NODE_ENV: tasks.util.env.dist ? 'production' : 'development' } });
gulp.src(src + 'scripts/app.js', { read: false })
.pipe(tasks.plumber())
.pipe(tasks.jshint())
.pipe(tasks.jshint.reporter('default'))
.pipe(tasks.browserify({
debug: tasks.util.env.dist,
insertGlobals: false,
transform: ['reactify'],
extensions: ['.jsx']
}))
.pipe(tasks.if(tasks.util.env.dist, tasks.uglify()))
.pipe(gulp.dest(dist))
.pipe(tasks.livereload());
}
);
gulp.task(
'workflow',
function () {
if (tasks.util.env.dist) {
return;
}
// Create gulp-open config file if it doesn't exist yet,
// and run the task either way
fs.stat(
open,
function (err) {
var cb = function() {
gulp.src('gulpfile.js')
.pipe(tasks.open('', require(open)));
};
if (null === err) {
cb();
} else {
console.log('gulp-open configuration file not found, creating it with default values...');
fs.writeFile(open, '{"url": "http://localhost:8000/app_dev.php"}', cb);
}
}
);
tasks.livereload.listen(
35729,
function (err) {
gulp.watch(src + 'stylesheets/**/*.less', ['stylesheets']);
gulp.watch(src + 'scripts/**/*', ['scripts']);
gulp.watch(
['app/Resources/views/**/*.twig', 'src/Airlines/AppBundle/Resources/views/**/*.twig'],
function () {
gulp.src('').pipe(tasks.livereload());
}
);
}
);
}
);
gulp.task('default', ['clean', 'stylesheets', 'fonts', 'scripts', 'workflow']);