Advertisement
Guest User

Untitled

a guest
May 29th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. // Paths
  2. var paths = {
  3. sources: "./src/**/*.js",
  4. sourceMain: "./src/index.js",
  5. tests: "./test/*.js",
  6. styles: "./styles",
  7. target: "./dist",
  8. targetMain: "bundle.js",
  9. targetMainMin: "bundle.min.js"
  10. }
  11.  
  12. // Gulp Dependencies
  13. var gulp = require('gulp');
  14. var rename = require('gulp-rename');
  15.  
  16. // Build Dependencies
  17. var browserify = require('gulp-browserify');
  18. var uglify = require('gulp-uglify');
  19.  
  20. // Style Dependencies
  21. var less = require('gulp-less');
  22. var prefix = require('gulp-autoprefixer');
  23. var minifyCSS = require('gulp-minify-css');
  24.  
  25. // Development Dependencies
  26. var jshint = require('gulp-jshint');
  27.  
  28. // Test Dependencies
  29. var mochaPhantomjs = require('gulp-mocha-phantomjs');
  30.  
  31. /** TESTING **/
  32. gulp.task('lint', function() {
  33. return gulp.src(paths.sources)
  34. .pipe(jshint())
  35. .pipe(jshint.reporter('default'));
  36. });
  37.  
  38. gulp.task('browserify', ['lint'], function() {
  39. return gulp.src(paths.sourceMain)
  40. .pipe(browserify({
  41. insertGlobals: true
  42. }))
  43. .pipe(rename(paths.targetMain))
  44. .pipe(gulp.dest(paths.target));
  45. });
  46.  
  47. gulp.task('test', ['browserify-test'], function() {
  48. return gulp.src('test/index.html')
  49. .pipe(mochaPhantomjs());
  50. });
  51.  
  52. /** if Client JS changes, re-browserify client and then re-lint and re-browserify Test **/
  53. gulp.task('watch', function() {
  54. gulp.watch(paths.sources, ['browserify', 'test']);
  55. gulp.watch(path.tests, ['test']);
  56. });
  57.  
  58.  
  59. gulp.task('uglify', ['browserify'], function() {
  60. return gulp.src(paths.targetMain)
  61. .pipe(uglify())
  62. .pipe(rename(paths.targetMainMin))
  63. .pipe(gulp.dest(paths.target));
  64. });
  65.  
  66. gulp.task('build', ['uglify', 'minify']);
  67.  
  68. /** use in development **/
  69. gulp.task("watch-dev", function(){
  70. gulp.watch(paths.sources, ['browserify']);
  71. gulp.watch(paths.styles, ['styles']);
  72. });
  73.  
  74. // Default Workflow
  75. // TEST does the lintering and browserifying
  76. gulp.task('default', ['test', 'build', 'watch']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement