-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (41 loc) · 1.62 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
prefix = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create();
// Setup static server
gulp.task('browser-sync', function() {
browserSync.init({
browser: "google chrome",
proxy: "regnsky:8888" // Ændr i forhold til den Mamp-host, der kører projektet
});
});
// Task to reload all Browsers
gulp.task('bs-reload', function() {
browserSync.reload();
});
gulp.task('sass', function() {
gulp.src('./sass/style.scss')
//.pipe(sourcemaps.init()) // init sourcemaps
.pipe(sass({
outputStyle: 'compressed'
})) // run sass - output styles: nested/compact/expanded/compressed
.pipe(prefix())
//.pipe(sourcemaps.write()) // write source maps
//.pipe(sass().on('error', sass.logError)) // Virker ikke lige nu
.pipe(gulp.dest('./')) // destination of compiled css file
.pipe(browserSync.stream()); // inject into browsers
});
// WATCH
gulp.task('watch', function() {
gulp.watch('./**/*.php', ['bs-reload']) // Watch php files and reload browsers
gulp.watch('./sass/**/*.scss', ['sass']) // Watch .scss files and call sass task
// When there is a change, display what file was changed, only showing the path after the 'sass folder'
.on('change', function(evt) {
console.log(
'[watcher] File ' + evt.path.replace(/.*(?=sass)/, '') + ' was ' + evt.type + ', compiling...'
);
});
});
// DEFAULT
gulp.task('default', ['sass', 'browser-sync', 'watch']);