Skip to content

Instantly share code, notes, and snippets.

@voter101
Last active October 16, 2024 17:37
Show Gist options
  • Select an option

  • Save voter101/9c824a30f712e7724cad to your computer and use it in GitHub Desktop.

Select an option

Save voter101/9c824a30f712e7724cad to your computer and use it in GitHub Desktop.

Revisions

  1. voter101 revised this gist Apr 28, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@ function compile(watch) {
    });
    }

    bundle()
    bundle();
    }

    gulp.task('default', ['compile-sass', 'compile-es6']);
  2. voter101 renamed this gist Apr 28, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. voter101 created this gist Apr 28, 2015.
    59 changes: 59 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    'use strict'

    var gulp, sass, babelify, browserify, watchify, source, util;

    gulp = require('gulp');
    sass = require('gulp-sass');
    babelify = require('babelify')
    browserify = require('browserify');
    watchify = require('watchify');
    source = require('vinyl-source-stream');
    util = require('gulp-util');

    var sassPath, sassSource, jsSource;

    sassPath = './app/assets/stylesheets/**/*.sass';
    sassSource = ['./app/assets/stylesheets/application.sass'];
    jsSource = './app/assets/javascripts/app.js';

    function compile(watch) {
    var bundler = watchify(browserify({entries: jsSource, debug: true}).transform(babelify));

    function bundle() {
    bundler.bundle()
    .on('error', util.log.bind(util, "Browserify Error"))
    .pipe(source('build.js'))
    .pipe(gulp.dest('./public/assets'))
    }

    if (watch) {
    bundler.on('update', function(){
    console.log("Recompiling JS...");
    bundle();
    });
    }

    bundle()
    }

    gulp.task('default', ['compile-sass', 'compile-es6']);

    gulp.task('compile-sass', function() {
    gulp.src(sassSource)
    .pipe(sass({ indentedSyntax: true, errLogToConsole: true }))
    .pipe(gulp.dest('public/stylesheets'))
    });

    gulp.task('compile-es6', function() {
    compile();
    });

    gulp.task('watch', ['watch-sass', 'watch-es6']);

    gulp.task('watch-sass', function() {
    gulp.watch(sassPath, ['compile-sass']);
    });

    gulp.task('watch-es6', function() {
    compile(true)
    });