Created
August 30, 2016 22:39
-
-
Save trevanhetzel/50689ed89e08c6b3ab3116486a974d56 to your computer and use it in GitHub Desktop.
Simple jQuery Mockjax & Browserify example
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
/** | |
* Main application file | |
*/ | |
'use strict'; | |
var $ = require('jquery'), | |
mockjax = require('jquery-mockjax')($, window); | |
$.mockjax({ | |
url: '/fakeurl', | |
responseText: { | |
status: 'success', | |
fortune: 'Are you a mock turtle?' | |
} | |
}); |
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
'use strict'; | |
var gulp = require('gulp'); | |
var buffer = require('vinyl-buffer'); | |
// Javascript | |
var browserify = require('browserify'); | |
var hbsfy = require('hbsfy'); | |
var source = require('vinyl-source-stream'); | |
var tasks = { | |
// ### JS processing pipeline | |
browserify: function () { | |
var bundler = browserify('./public/assets/scripts/app.js', { | |
debug: production, | |
cache: {} | |
}); | |
return bundler.transform(hbsfy, { traverse: true }) | |
.bundle() | |
.pipe(source('app.js')) | |
.pipe(buffer()) | |
.pipe(gulp.dest('./public/dist/scripts/')) | |
.pipe(notify({message: 'JavaScript compiled!'})); | |
} | |
}; | |
gulp.task('browserify', tasks.browserify); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice example. Thank you!