yoesoff

tasks/bower.task.js

May 16th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. /*Elixir Task for bower
  2. * Upgraded from https://github.com/ansata-biz/laravel-elixir-bower
  3. */
  4. var gulp = require('gulp');
  5. var mainBowerFiles = require('main-bower-files');
  6. var filter = require('gulp-filter');
  7. var notify = require('gulp-notify');
  8. var minify = require('gulp-minify-css');
  9. var uglify = require('gulp-uglify');
  10. var concat_sm = require('gulp-concat-sourcemap');
  11. var concat = require('gulp-concat');
  12. var gulpIf = require('gulp-if');
  13.  
  14. var Elixir = require('laravel-elixir');
  15.  
  16. var Task = Elixir.Task;
  17.  
  18. Elixir.extend('bower', function(jsOutputFile, jsOutputFolder, cssOutputFile, cssOutputFolder) {
  19.  
  20. var cssFile = cssOutputFile || 'vendor.css';
  21. var jsFile = jsOutputFile || 'vendor.js';
  22.  
  23. if (!Elixir.config.production){
  24. concat = concat_sm;
  25. }
  26.  
  27. var onError = function (err) {
  28. notify.onError({
  29. title: "Laravel Elixir",
  30. subtitle: "Bower Files Compilation Failed!",
  31. message: "Error: <%= error.message %>",
  32. icon: __dirname + '/../node_modules/laravel-elixir/icons/fail.png'
  33. })(err);
  34. this.emit('end');
  35. };
  36.  
  37. new Task('bower-js', function() {
  38. return gulp.src(mainBowerFiles())
  39. .on('error', onError)
  40. .pipe(filter('**/*.js'))
  41. .pipe(concat(jsFile, {sourcesContent: true}))
  42. .pipe(gulpIf(Elixir.config.production, uglify()))
  43. .pipe(gulp.dest(jsOutputFolder || Elixir.config.js.outputFolder))
  44. .pipe(notify({
  45. title: 'Laravel Elixir',
  46. subtitle: 'Javascript Bower Files Imported!',
  47. icon: __dirname + '/../node_modules/laravel-elixir/icons/laravel.png',
  48. message: ' '
  49. }));
  50. }).watch('bower.json');
  51.  
  52.  
  53. new Task('bower-css', function(){
  54. return gulp.src(mainBowerFiles())
  55. .on('error', onError)
  56. .pipe(filter('**/*.css'))
  57. .pipe(concat(cssFile))
  58. .pipe(gulpIf(config.production, minify()))
  59. .pipe(gulp.dest(cssOutputFolder || config.css.outputFolder))
  60. .pipe(notify({
  61. title: 'Laravel Elixir',
  62. subtitle: 'CSS Bower Files Imported!',
  63. icon: __dirname + '/../node_modules/laravel-elixir/icons/laravel.png',
  64. message: ' '
  65. }));
  66. }).watch('bower.json');
  67.  
  68. });
Advertisement
Add Comment
Please, Sign In to add comment