-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (57 loc) · 1.79 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const uglify = require('gulp-uglify');
const postcss = require('gulp-postcss');
const purgecss = require('gulp-purgecss');
const tailwindcss = require('tailwindcss');
const gulpTS = require('gulp-typescript');
function css() {
return gulp.src('./src/css/*.scss')
.pipe(sass())
.pipe(postcss([
tailwindcss('./tailwind.config.js')
]))
.pipe(purgecss({
content: ['./src/**/*.ejs', './src/**/*.scss'],
extractors: [
{
extractor: content => {
return content.match(/[A-z0-9-:\/]+/g) || [];
},
extensions: ['scss', 'ejs']
}
]
}))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(concat('app.css'))
.pipe(gulp.dest('./public/css'));
}
function ts() {
return gulp.src(['./src/js/**/*.ts', './node_modules/alpinejs/dist/alpine.js', './node_modules/sortablejs/Sortable.js'])
.pipe(gulpTS({allowJs: true}))
.pipe(babel())
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/js'));
}
function js() {
return gulp.src('./src/js/**/*.js')
.pipe(babel())
//.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/js'));
}
function watch() {
gulp.watch('./src/css/*.scss', css);
gulp.watch('./src/**/*.js', js);
gulp.watch('./src/**/*.ts', ts);
gulp.watch('./src/**/*.ejs', css);
}
gulp.task(css);
gulp.task(js);
gulp.task(ts);
gulp.task(watch);
gulp.task('default', gulp.parallel(css, ts, js, watch));