-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (50 loc) · 1.71 KB
/
gulpfile.js
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
const gulp = require('gulp');
const sass = require('gulp-dart-sass');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const tailwindcss = require('tailwindcss');
const browserSync = require('browser-sync').create();
// Move image files
gulp.task('images', () => {
return gulp.src('src/images/**/*').pipe(gulp.dest('dist/images'));
});
// Move JS files
gulp.task('js', () => {
return gulp.src('src/js/**/*').pipe(gulp.dest('dist/js'));
});
// Move the swiper-bundle.css file to the dist/js folder
gulp.task('move-swiper-css', () => {
return gulp
.src('./node_modules/swiper/swiper-bundle.min.css')
.pipe(gulp.dest('dist/css/lib'));
});
// Compile SCSS to CSS with Tailwind CSS
gulp.task('css', () => {
return gulp
.src('src/scss/**/*')
.pipe(sass().on('error', sass.logError))
.pipe(postcss([tailwindcss, autoprefixer()]))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.stream()); // Reload the browser when changes are made to SCSS files
});
// Update CSS file reference in HTML
gulp.task('html', () => {
return gulp
.src('src/*.html')
.pipe(gulp.dest('dist'));
});
// Watch for changes and update the browser
gulp.task('watch', () => {
browserSync.init({
server: {
baseDir: './dist',
},
});
gulp.watch('src/**/*.scss', gulp.series('css'));
gulp.watch('src/**/*.js', gulp.series('js'));
gulp.watch('src/**/*.html', gulp.series('html')).on('change', browserSync.reload);
});
// Build task: Run the 'css' task and then 'html', 'images', and 'js'
gulp.task('build', gulp.series('css', 'html', 'images', 'js'));
// Default task: Run the 'build' task and then watch for changes
gulp.task('default', gulp.series('build', 'watch'));