-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·87 lines (75 loc) · 2.26 KB
/
Copy pathgulpfile.js
File metadata and controls
executable file
·87 lines (75 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* Gulpfile for Academic Portfolio Website
*
* This build system supports Bootstrap 5 (no jQuery required) and provides:
* - Vendor file management (Bootstrap 5)
* - CSS minification for custom stylesheets
* - Development server with live reload
*
* Available tasks:
* - gulp vendor: Copy Bootstrap 5 from node_modules to vendor directory
* - gulp css: Minify custom CSS files
* - gulp dev: Start development server with live reload
* - gulp clean: Remove old vendor files (jQuery)
*/
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
const fs = require('fs');
const path = require('path');
// Clean old vendor files (jQuery no longer needed with Bootstrap 5)
function cleanVendor(cb) {
const jqueryPath = './vendor/jquery';
if (fs.existsSync(jqueryPath)) {
fs.rmSync(jqueryPath, { recursive: true, force: true });
console.log('Removed jQuery vendor directory (no longer needed with Bootstrap 5)');
}
cb();
}
// Copy third party libraries from /node_modules into /vendor
function vendor() {
// Bootstrap
return gulp.src([
'./node_modules/bootstrap/dist/**/*',
'!./node_modules/bootstrap/dist/css/bootstrap-grid*',
'!./node_modules/bootstrap/dist/css/bootstrap-reboot*'
])
.pipe(gulp.dest('./vendor/bootstrap'));
}
// Minify custom CSS
function minifyCSS() {
return gulp.src(['./css/*.css', '!./css/*.min.css'])
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./css'));
}
// Configure the browserSync task
function browserSyncServe(cb) {
browserSync.init({
server: {
baseDir: "./"
}
});
cb();
}
// BrowserSync reload
function browserSyncReload(cb) {
browserSync.reload();
cb();
}
// Watch files
function watchFiles() {
gulp.watch('./css/*.css', gulp.series(browserSyncReload));
gulp.watch('./*.html', gulp.series(browserSyncReload));
}
// Clean task
exports.clean = cleanVendor;
// Vendor task (clean old files first, then copy new ones)
exports.vendor = gulp.series(cleanVendor, vendor);
// CSS minification task
exports.css = minifyCSS;
// Dev task
exports.dev = gulp.series(browserSyncServe, watchFiles);
// Default task
exports.default = exports.vendor;