Personal portfolio website created with bootstrap.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.1 KiB

  1. var gulp = require('gulp');
  2. var sass = require('gulp-sass');
  3. var browserSync = require('browser-sync').create();
  4. var header = require('gulp-header');
  5. var cleanCSS = require('gulp-clean-css');
  6. var rename = require("gulp-rename");
  7. var uglify = require('gulp-uglify');
  8. var filter = require('gulp-filter');
  9. var pkg = require('./package.json');
  10. // Set the banner content
  11. var banner = ['/*!\n',
  12. ' * Start Bootstrap - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
  13. ' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
  14. ' * Licensed under <%= pkg.license %> (https://github.com/BlackrockDigital/<%= pkg.name %>/blob/master/LICENSE)\n',
  15. ' */\n',
  16. ''
  17. ].join('');
  18. // Compiles SCSS files from /scss into /css
  19. gulp.task('sass', function() {
  20. return gulp.src('scss/freelancer.scss')
  21. .pipe(sass())
  22. .pipe(header(banner, {
  23. pkg: pkg
  24. }))
  25. .pipe(gulp.dest('css'))
  26. .pipe(browserSync.reload({
  27. stream: true
  28. }))
  29. });
  30. // Minify compiled CSS
  31. gulp.task('minify-css', ['sass'], function() {
  32. return gulp.src('css/freelancer.css')
  33. .pipe(cleanCSS({
  34. compatibility: 'ie8'
  35. }))
  36. .pipe(rename({
  37. suffix: '.min'
  38. }))
  39. .pipe(gulp.dest('css'))
  40. .pipe(browserSync.reload({
  41. stream: true
  42. }))
  43. });
  44. // Minify custom JS
  45. gulp.task('minify-js', function() {
  46. return gulp.src('js/freelancer.js')
  47. .pipe(uglify())
  48. .pipe(header(banner, {
  49. pkg: pkg
  50. }))
  51. .pipe(rename({
  52. suffix: '.min'
  53. }))
  54. .pipe(gulp.dest('js'))
  55. .pipe(browserSync.reload({
  56. stream: true
  57. }))
  58. });
  59. // Copy vendor files from /node_modules into /vendor
  60. // NOTE: requires `npm install` before running!
  61. gulp.task('copy', function() {
  62. gulp.src([
  63. 'node_modules/bootstrap/dist/**/*',
  64. '!**/npm.js',
  65. '!**/bootstrap-theme.*',
  66. '!**/*.map'
  67. ])
  68. .pipe(gulp.dest('vendor/bootstrap'))
  69. gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
  70. .pipe(gulp.dest('vendor/jquery'))
  71. gulp.src(['node_modules/popper.js/dist/umd/popper.js', 'node_modules/popper.js/dist/umd/popper.min.js'])
  72. .pipe(gulp.dest('vendor/popper'))
  73. gulp.src(['node_modules/jquery.easing/*.js'])
  74. .pipe(gulp.dest('vendor/jquery-easing'))
  75. gulp.src([
  76. 'node_modules/font-awesome/**',
  77. '!node_modules/font-awesome/**/*.map',
  78. '!node_modules/font-awesome/.npmignore',
  79. '!node_modules/font-awesome/*.txt',
  80. '!node_modules/font-awesome/*.md',
  81. '!node_modules/font-awesome/*.json'
  82. ])
  83. .pipe(gulp.dest('vendor/font-awesome'))
  84. })
  85. // Default task
  86. gulp.task('default', ['sass', 'minify-css', 'minify-js', 'copy']);
  87. // Configure the browserSync task
  88. gulp.task('browserSync', function() {
  89. browserSync.init({
  90. server: {
  91. baseDir: ''
  92. },
  93. })
  94. })
  95. // Dev task with browserSync
  96. gulp.task('dev', ['browserSync', 'sass', 'minify-css', 'minify-js'], function() {
  97. gulp.watch('scss/*.scss', ['sass']);
  98. gulp.watch('css/*.css', ['minify-css']);
  99. gulp.watch('js/*.js', ['minify-js']);
  100. // Reloads the browser whenever HTML or JS files change
  101. gulp.watch('*.html', browserSync.reload);
  102. gulp.watch('js/**/*.js', browserSync.reload);
  103. });