This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (72 loc) · 2.04 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
81
82
83
84
var gulp = require('gulp');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
var postcssimport = require('postcss-import');
var tailwind = require('tailwindcss');
var sourcemaps = require('gulp-sourcemaps');
var nested = require('postcss-nested');
var purgecss = require('gulp-purgecss');
var concat = require('gulp-concat');
//var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
gulp.task('sass', function () {
var processors = [
postcssimport,
tailwind,
nested,
autoprefixer,
];
return gulp.src('./src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss(processors))
.pipe(purgecss({
content: ['./**/*.php']
}))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('sass-min', function () {
var processors = [
postcssimport,
tailwind,
nested,
autoprefixer,
cssnano
];
return gulp.src('./src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss(processors))
.pipe(purgecss({
content: ['./**/*.php']
}))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('scripts', function () {
var jsFiles = './src/js/**/*.js',
jsDest = './dist/js';
return gulp.src(jsFiles)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest));
});
gulp.task('scripts-min', function () {
var jsFiles = './src/js/**/*.js',
jsDest = './dist/js';
return gulp.src(jsFiles)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest))
.pipe(uglify())
.pipe(gulp.dest(jsDest));
});
//compile and watch
gulp.task('watch', function () {
gulp.watch('./**/*.php', gulp.series('sass'));
gulp.watch('src/scss/*.scss', gulp.series('sass'));
gulp.watch('src/js/**/*.js', gulp.series('scripts'));
});
//compile and minify, watch
gulp.task('build', function () {
gulp.watch('./**/*.php', gulp.series('sass-min'));
gulp.watch('src/scss/**/*.scss', gulp.series('sass-min'));
gulp.watch('src/js/**/*.js', gulp.series('scripts-min'));
});