Advertisement
bananamariap

GULP and BOWER

Jun 9th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. Installing third party packages using Bower and Gulp
  2.  
  3. INSTALLING BOWER:
  4. npm install -g bower
  5. bower init - bower.json file will be created
  6. touch .bowerrc - .bowerrc file will be created if you want to change the default directory of bower packages that you install: Default bower directory is bower_components/
  7. bower install
  8. bower install --save [package name] - NOTE: do not forget --save so packages will be added to dependencies of your bower.json
  9.  
  10. REQUIRED PACKAGES:
  11. concat = require('gulp-concat'),
  12. bower = require('gulp-bower'),
  13. mainBowerFiles = require('main-bower-files'),
  14. uglify = require('gulp-uglify'),
  15. filter = require('gulp-filter');
  16.  
  17. GULP TASKS:
  18. /**
  19. * Let us define source and destination folder path
  20. */
  21. var src = 'src/',
  22. dest = 'dist/';
  23.  
  24. // Include plugins
  25. var plugins = require("gulp-load-plugins")({
  26. pattern: ['gulp-*', 'gulp.*', 'main-bower-files'],
  27. replaceString: /\bgulp[\-.]/,
  28. });
  29.  
  30.  
  31. gulp.task('js:plugin', function() {
  32. return gulp.src(plugins.mainBowerFiles({
  33. debugging: true
  34. }))
  35. .pipe(plugins.filter(['**/*.js', '!**/*.min.js']))
  36. .pipe(plugins.concat('plugin.min.js'))
  37. .pipe(plugins.uglify())
  38. .pipe(gulp.dest(dest + 'js'));
  39. });
  40.  
  41. gulp.task('css:plugin', function() {
  42. return gulp.src(plugins.mainBowerFiles({
  43. debugging: true,
  44. }))
  45. .pipe(plugins.filter(['**/*.css', '!**/*.min.css']))
  46. .pipe(autoprefixer())
  47. .pipe(plugins.concat('plugin.min.css'))
  48. .pipe(gulp.dest(dest + 'css'));
  49. });
  50.  
  51.  
  52. SAMPLE bower.json file:
  53. {
  54. "name": "wbtlaw.com",
  55. "description": "Custom WordPress Theme for wbtlaw.com",
  56. "main": "",
  57. "authors": [
  58. "Afterfive by Design | afterfivebydesign.com"
  59. ],
  60. "license": "MIT",
  61. "homepage": "www.wbtlaw.com",
  62. "ignore": [
  63. "**/.*",
  64. "node_modules",
  65. "bower_components",
  66. "test",
  67. "tests"
  68. ],
  69. "private": true,
  70. "dependencies": {
  71. "vis": "^4.20.0",
  72. }
  73. }
  74.  
  75. SAMPLE .bowerrc file:
  76. {
  77. "directory" : "src/components"
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement