-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (55 loc) · 1.46 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 terser = require('gulp-terser');
const isProduction = process.env.NODE_ENV === 'production';
const src = 'src';
const outputDirectory = 'dist';
function javascriptTask() {
return gulp.src(`${src}/**/*.js`)
.pipe(babel({
"presets": [
[
"@babel/preset-env",
{
modules: false,
targets: "> 0.25%, not dead"
}
]
]
}))
.pipe(terser())
.pipe(gulp.dest(outputDirectory))
}
function cssTask() {
const postcss = require('gulp-postcss');
return gulp.src(`${src}/**/*.css`, {base: src})
.pipe(postcss([
require('tailwindcss'),
require('autoprefixer'),
require('@fullhuman/postcss-purgecss')({
content: [
'./src/**/*.ftl',
],
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
}),
isProduction && require('cssnano')({
preset: 'default',
}),
].filter(Boolean)))
.pipe(gulp.dest(outputDirectory))
}
function templatesTask() {
return gulp.src([`${src}/**/*`, `!${src}/**/*.js`, `!${src}/**/*.css`], {base: src})
.pipe(gulp.dest(outputDirectory));
}
function watchTask() {
return gulp.watch(`${src}/**/*`,
gulp.parallel(
javascriptTask,
cssTask,
templatesTask
)
);
}
exports.default = gulp.series(gulp.parallel(javascriptTask, cssTask, templatesTask));
exports.watch = watchTask;