0.0.3 • Published 7 years ago

gulp-filemod v0.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Gulp Filemod

Forks gulp-wrap-file package

This is just a bit less code, and automatic error logging and catching issues.
I simply got annoyed with all the extra code and lac of documentation on Ember precompilation WIHTOUT EmberCli. Have a project at work that was built in ember before the cli happened, and it's too hard to transition... :) Love this way.

Enjoy!

// some samples available within the package
// node_modules/package-test/*

// Examples
var gulp = require('gulp');
var concat = require('gulp-concat');
var filemod = require('gulp-filemod');
var embtc = require('./bower_components/ember/ember-template-compiler');
var colors = require('colors');


gulp.task('default', ()=>{
    return gulp.src('./sources/**/*.js')
        .pipe(filemod((err,file)=>{
            if(err){
                // handle error`
            }else{
                return file.contents;            
            }
        }));
});

// here's an example how to precompile ember templates without EmberCLi
gulp.task('default', ()=> {
    return gulp.src('./sources/**/*.hbs')
        .pipe(filemod((err, file) => {
            if (err) {
                return err.content;
            } else {
                var template = embtc.precompile(file.content);
                var name = file.name;
                var template = `Ember.TEMPLATES["${name}"] = Ember.Handlebars.template(${template})`;
                return template;
            }
        }))
        .pipe(concat('file.js'))
        .pipe(gulp.dest('./dest'));
});