I try to integrate Live CSS Injection into my Wordpress Project with GULP. Here is my current set up:
gulpfile.js:
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
// Init Browser-Sync
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "http://localhost:8888/buergerrat.at/",
notify: true,
injectChanges: true,
browser: "Google Chrome"
});
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("*.scss") // Gets all files ending with .scss
.pipe(sass())
.pipe(gulp.dest("./"))
.pipe(browserSync.reload({ stream: true }))
});
/* Watch Files */
gulp.task('default', ['sass', 'browser-sync'], function (){
gulp.watch('*.scss', ['sass']);
});
In the Terminal I get following message:
[22:13:14] Starting 'sass'...
[Browsersync] 1 file changed (style.css)
[22:13:14] Finished 'sass' after 8 ms
And in the Browser-Console it says:
22:12:59 ✨ Browsersync reloading stylesheet: http://localhost:3000/buergerrat.at/wp-content/themes/wordpressTheme/style.css?ver=5.0-alpha-42425&browsersync=1515013964239
Has anyone an idea, what I got wrong? The sass file is correctly rendered, so when I reload the page manualy the changes take affect.
Thanks a lot!! :)