Skip to content

Instantly share code, notes, and snippets.

@quagliero
Last active January 31, 2017 16:12
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quagliero/8912555 to your computer and use it in GitHub Desktop.
Save quagliero/8912555 to your computer and use it in GitHub Desktop.
Gulpfile for Symfony2 Bundle assets (non-production)
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']);
@ollietb
Copy link

ollietb commented Jul 1, 2014

You can try using Gassetic which is an Assetic replacement for Symfony2 using gulp and bower https://github.com/crossborne/gassetic/blob/master/Resources/doc/GasseticAndSymfony2.md

@quagliero
Copy link
Author

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment