-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·75 lines (66 loc) · 2.42 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
const { src, dest, watch, series, parallel } = require('gulp');
const sass = require('gulp-dart-sass'); // Gebruik gulp-dart-sass om de Legacy API te vermijden
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const cleanCSS = require('gulp-clean-css');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
const path = require('path');
// Pad naar je SSL-certificaat en sleutel (pas deze paden aan naar je eigen certificaten)
const certPath = path.join('/Applications/ServBay/ssl/private/tls-certs/eskobar.local', 'eskobar.local.crt');
const keyPath = path.join('/Applications/ServBay/ssl/private/tls-certs/eskobar.local', 'eskobar.local.key');
// Compile Sass naar CSS
function compileSass() {
const sass = require('gulp-dart-sass');
console.log('Loaded gulp-dart-sass version:', sass.compiler.info);
return src('web/assets/sass/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss([autoprefixer()]))
.pipe(concat('style.css'))
.pipe(dest('web/assets/css'))
.pipe(browserSync.stream());
}
// Minify CSS
function minifyCSS() {
return src('web/assets/css/style.css', { allowEmpty: true })
.pipe(cleanCSS({ compatibility: 'ie8' }).on('error', (err) => {
console.error('Error in clean-css:', err.message);
}))
.pipe(concat('style.min.css'))
.pipe(dest('web/assets/css'));
}
// BrowserSync initialiseren
function initBrowserSync(done) {
browserSync.init({
proxy: {
target: "http://eskobar.local", // Zorg ervoor dat dit je lokale domein is
proxyReq: [
function(proxyReq) {
proxyReq.setHeader('Host', 'eskobar.local');
}
]
},
notify: false,
open: false,
files: [],
host: "eskobar.local",
port: 3000,
https: false,
// https: {
// key: keyPath,
// cert: certPath
// },
});
done();
}
// Watch voor wijzigingen
function watchFiles() {
watch('web/assets/sass/**/*.scss', series(compileSass, minifyCSS)); // Genereert style.css en min.css
watch('web/assets/css/style.min.css').on('change', browserSync.reload); // Alleen minified bestand monitoren
}
// Default task
exports.default = series(
parallel(compileSass, minifyCSS),
initBrowserSync,
watchFiles
);