-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpFile.js
More file actions
62 lines (47 loc) · 1.69 KB
/
Copy pathGulpFile.js
File metadata and controls
62 lines (47 loc) · 1.69 KB
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
var gulp = require('gulp'),
sass = require('gulp-sass'),
cleanCSS = require('gulp-clean-css'),
exec = require('child_process').exec,
livereload = require('gulp-livereload'),
concat = require('gulp-concat'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify');
function swallowError (error) {
console.log(error.toString())
this.emit('end')
}
gulp.task('sass-dev', function () {
gulp.src('./web/bundles/app/sass/master.scss')
.pipe(sass({sourceComments: 'map'}))
.on('error', swallowError)
.pipe(gulp.dest('./web/css/'));
});
gulp.task('sass-prod', function () {
gulp.src('./web/bundles/app/sass/master.scss')
.pipe(sass({sourceComments: 'map'}))
.pipe(cleanCSS({compatibility: 'ie8', processImportFrom: ['!fonts.googleapis.com']}))
.on('error', swallowError)
.pipe(gulp.dest('./web/css/'));
});
var livereload = require('gulp-livereload');
gulp.task('watch', function () {
var onChange = function (event) {
console.log('File '+event.path+' has been '+event.type);
gulp.task('reload', ['installAssets', 'sass-dev']);
// Tell LiveReload to reload the window
livereload.changed(event.path);
};
// Starts the server
livereload.listen();
gulp.watch('./src/*/Resources/public/sass/**/*.scss', ['sass-dev'])
.on('change', onChange);
});
gulp.task('installAssets', function () {
exec('php bin/console assets:install --symlink', function (err, stdout, stderr) {
console.log(stdout + stderr);
});
});
gulp.task('default', ['sass-dev']);
gulp.task('dev', ['sass-dev']);
gulp.task('prod', ['sass-prod']);