Last active
January 31, 2017 16:12
-
-
Save quagliero/8912555 to your computer and use it in GitHub Desktop.
Gulpfile for Symfony2 Bundle assets (non-production)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var sass = require('gulp-ruby-sass'); | |
// var sass = require('gulp-sass'); | |
var jshint = require('gulp-jshint'); | |
var concat = require('gulp-concat'); | |
var rename = require('gulp-rename'); | |
var browserSync = require('browser-sync'); | |
var url = 'site.dev'; | |
var basePath = './path/to/bundle/public/resources'; | |
var assets = { | |
scripts: [ | |
basePath + '/js/**/libs/*.js', | |
basePath + '/js/**/plugins/*.js', | |
basePath + '/js/**/components/*.js', | |
], | |
sass: basePath + '/css/style.scss' | |
} | |
gulp.task('browser-sync', function() { | |
browserSync.init([ | |
basePath + '/css/dev.css', | |
basePath + '/js/dev.js', | |
basePath + '/../views/**/*.html.twig' | |
], { | |
proxy: { | |
host: url | |
} | |
}); | |
}); | |
gulp.task('lint', function() { | |
gulp.src(basePath + '/js/**/components/*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')) | |
}); | |
gulp.task('sass', function() { | |
gulp.src(assets.sass) | |
.pipe(sass({debugInfo: true})) | |
.pipe(rename('dev.css')) | |
.pipe(gulp.dest(basePath + '/css')) | |
}); | |
/* | |
* For when they figure this out -- https://github.com/hcatlin/libsass/issues/146 | |
* | |
gulp.task('sass', function() { | |
gulp.src(paths.base + '/css/style.scss') | |
.pipe(sass({ includePaths: [paths.base + '/css'], errLogToConsole: true })) | |
.pipe(gulp.dest(paths.base + '/css')); | |
}); | |
*/ | |
gulp.task('scripts', function() { | |
gulp.src(assets.scripts) | |
.pipe(concat('dev.js')) | |
.pipe(gulp.dest(basePath + '/js')) | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(basePath + '/css/**/*.scss', ['sass']); | |
gulp.watch(basePath + '/js/**/components/*.js', ['lint']); | |
gulp.watch(basePath + '/js/**/*.js', ['scripts']); | |
}); | |
gulp.task('default', ['sass','lint','scripts','browser-sync','watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @ollietb, I'll definitely check that out. The symfony-gulp relationship has always felt rather shoe-horned and didn't really work very well with multiple bundles. Nice to see a solution taking shape 👍