-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
80 lines (71 loc) · 2.58 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const less = require('gulp-less');
const typescript = require('gulp-typescript');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const cleanCSS = require('gulp-clean-css');
const watch = require('gulp-watch');
// Task for minifying CSS files
gulp.task('minify-css', function () {
return gulp.src('resources/assets/css/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('public/css'));
});
// Task for compiling Sass
gulp.task('sass', function () {
return gulp.src('resources/assets/css/*.scss')
.pipe(sass())
.pipe(cleanCSS())
.pipe(gulp.dest('public/css'));
});
// Task for compiling Less
gulp.task('less', function () {
return gulp.src('resources/assets/css/*.less')
.pipe(less())
.pipe(cleanCSS())
.pipe(gulp.dest('public/css'));
});
// Task for minifying JavaScript files
gulp.task('minify-js', function () {
return gulp.src('resources/assets/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
// Task for compiling TypeScript
gulp.task('typescript', function () {
return gulp.src('resources/assets/js/*.ts')
.pipe(typescript())
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
// Task for compiling React JSX
gulp.task('react', function () {
return gulp.src('resources/assets/js/*.jsx')
.pipe(babel({
presets: ['@babel/preset-env', '@babel/preset-react']
}))
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
// Task for compiling React TSX
gulp.task('react-tsx', function () {
return gulp.src('resources/assets/js/*.tsx')
.pipe(babel({
presets: ['@babel/preset-env', '@babel/preset-react']
}))
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
// Task for watching changes in CSS and JavaScript files
gulp.task('watch', function () {
gulp.watch('resources/assets/css/**/*.css', gulp.series('minify-css'));
gulp.watch('resources/assets/css/**/*.scss', gulp.series('sass'));
gulp.watch('resources/assets/css/**/*.less', gulp.series('less'));
gulp.watch('resources/assets/js/**/*.ts', gulp.series('typescript'));
gulp.watch('resources/assets/js/**/*.jsx', gulp.series('react'));
gulp.watch('resources/assets/js/**/*.tsx', gulp.series('react-tsx'));
gulp.watch('resources/assets/js/**/*.js', gulp.series('minify-js'));
});
// Default task to run all tasks
gulp.task('build', gulp.parallel('minify-css', 'sass', 'less', 'minify-js', 'typescript', 'react', 'react-tsx',));