When one of the gulp.watch
tasks is fired (css:dist, mostly), I get one of the following errors: Abort Trap 6
or Segmentation fault: 11
. Also, it's only happened once, but I got another error message displayed after Gulp halted: Trace/BPT trap: 5
. The segfault error is the one I'm running into most frequently, though. Gulp halts maybe every 4 or 5 times I modify/save one of the SCSS files that are under watch. I've had it happen for other files that are being watched, too.
I've tried just about everything. brew upgrade
and brew update
haven't seemed to improve anything. I've tried clearing out all node modules from the project and reinstalling, updating all of those packages, restarting the machine, verifying disk permissions, etc. Nothing has helped.
I thought I'd found the answer when I stumbled upon this question, but it went unanswered and dormant. Some open issues on GitHub suggest that it may be the fault of Gaze, gulp-sass, or rtorrent in Homebrew (which I don't think I'm using unless it's a dependency).
Running on Mac OSX Yosemite. Here is my Gulpfile:
var fs = require('fs'),
argv = require('yargs').argv,
browserify = require('browserify'),
transform = require('vinyl-transform'),
browserSync = require('browser-sync'),
gulp = require('gulp'),
del = require('del'),
sass = require('gulp-sass'),
prefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
minify = require('gulp-minify-css'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
config = {
browserSync_proxy: 'dev.example.com',
bower_path: './bower_components/',
template_src: ['resources/views/*.blade.php', 'resources/views/**/*.blade.php'],
js_src: ['resources/assets/js/*.js', 'resources/assets/js/**/*.js'],
sass_src: ['resources/assets/scss/*.scss', 'resources/assets/scss/**/*.scss'],
img_src: ['resources/assets/img/**/*', 'resources/assets/img/*'],
js_dist: 'public/assets/js/',
js_clean_path: 'public/assets/js/**/*',
css_dist: 'public/assets/css/',
css_clean_path: 'public/assets/css/**/*',
img_dist: 'public/assets/img/'
};
/*
** Update bower component path if .bowerrc file exists
*/
if (fs.existsSync('.bowerrc')) {
var bower_config = JSON.parse(fs.readFileSync('.bowerrc')),
bower_dir = bower_config.directory;
config.bower_path = (bower_dir.substr(bower_dir.length, -1) !== "/") ? bower_dir + "/" : bower_dir;
}
/*
** Start browser sync
*/
if(argv.sync !== 0) {
browserSync({
proxy: config.browserSync_proxy,
host: config.browserSync_proxy,
open: 'external'
});
}
/*
** CSS: Clean destination folder before processing css
*/
gulp.task('css:clean', function() {
del([config.css_clean_path], function(err,paths) {
console.log("Cleaned CSS:\n", paths.join('\n'));
});
});
/*
** CSS: Compile sass, add autoprefixer and minify
*/
gulp.task('css:dist', ['css:clean'], function() {
return gulp.src(config.sass_src)
.pipe(sourcemaps.init())
.pipe(sass({
sourceComments: 'none',
includePaths: [
config.bower_path + 'normalize-scss',
config.bower_path + 'bourbon/app/assets/stylesheets',
config.bower_path + 'neat/app/assets/stylesheets',
config.bower_path + 'slick-carousel/slick'
]
}))
.pipe(prefixer({
browsers: ['last 2 versions']
}))
.pipe(minify({
keepSpecialComments: 0
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.css_dist));
});
/*
** JS: Clean js folder before processing scripts
*/
gulp.task('js:clean', function() {
del([config.js_clean_path], function(err,paths) {
console.log("Cleaned JS:\n", paths.join('\n'));
});
});
/*
** JS: Combine vendor js files
*/
gulp.task('js:vendor', function() {
return gulp.src([
config.bower_path + 'jquery/dist/jquery.js',
config.bower_path + 'modernizr/modernizr.js',
config.bower_path + 'fastclick/lib/fastclick.js',
config.bower_path + 'slick-carousel/slick/slick.js',
config.bower_path + 'frame-events/frame-events.js'
])
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(config.js_dist));
});
/*
** JS: Build via Browserify
*/
gulp.task('js:browserify', function() {
var browserifyTrans = transform(function(file) {
var browserified = browserify(file);
return browserified.bundle();
});
return gulp.src([config.js_src[0]])
.pipe(browserifyTrans)
.pipe(gulp.dest(config.js_dist));
});
/*
** JS: Build main app files via browserify
*/
gulp.task('js:dist', ['js:clean', 'js:vendor', 'js:browserify'], function() {
return gulp.src([config.js_dist + '/**/*.js'])
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(config.js_dist));
});
/*
** IMG: Run imagemin on all images
*/
gulp.task('img:dist', function() {
gulp.src(config.img_src).pipe(imagemin({
optimizationLevel: 0,
progressive: true,
svgoPlugins: [{
removeViewBox: false
}, {
removeEmptyAttrs: true
}, {
collapseGroups: false
}]
}))
.pipe(gulp.dest(config.img_dist));
});
/*
** Default Task
*/
gulp.task('default', ['css:dist', 'js:dist', 'img:dist'], function() {
/*
** Initial file observers
*/
gulp.watch(config.js_src, ['js:dist']);
gulp.watch(config.sass_src, ['css:dist']);
gulp.watch(config.img_src, ['img:dist']);
gulp.watch([
config.template_src,
config.js_dist + '*.js',
config.css_dist + '*.css'
]).on('change', browserSync.reload);
});
Anybody know what this could possibly be caused by? Thanks in advance for taking a look at this.
Update :: I've got GDB setup on my machine to hopefully track down the issue, but GDB doesn't seem to be acknowledging the live watch
updates from Gulp, so no help there. Does anybody know how to get GDB to allow these gulp.watch
tasks to be observed?