Kirby 3, Gulp, local development

Hi Kirby-Fellaz!

My gulp watch - task (watch-txt)
hangs when i switch the status
(Draft, In Review, Published) in
the panel.

I think the renaming of the folders
to _drafts etc. causes the ENOENT error.

Error: watch /Users/superuser/Sites/kirby/kirby/content/2_notes/20190211_test/ ENOENT

Everything else works perfectly
and like expected.

Any help would be greatly appreciated.

Saludos, Funkybrotha

By the way… anyone made already the
switch from gulp 3 to 4?

gulpfile.js

var gulp        = require('gulp'); // 3.9.1
var php         = require('gulp-connect-php');
var browserSync = require('browser-sync').create();
var plumber     = require('gulp-plumber');
var gutil       = require('gulp-util');
var watch       = require('gulp-watch');

gulp.task('php', function() {
  php.server({
    base: './kirby/',
    port: 8010,
    keepalive: true,
    router: './kirby/kirby/router.php'
  });
});

gulp.task('watch-php', function () {
  return gulp.src('./kirby/site/**/*.php')
  .pipe(watch('./kirby/site/**/*.php'))
  .pipe(plumber())
  .pipe(browserSync.reload({stream: true}))
  .on('error', gutil.log);
});

gulp.task('watch-txt', function () {
  return gulp.src('./kirby/content/**/*.txt')
  .pipe(watch('./kirby/content/**/*.txt'))
  .pipe(plumber())
  .pipe(browserSync.reload({stream: true}))
  .on('error', gutil.log);
});

gulp.task('browserSync', ['php'], function() {
  browserSync.init({
    injectChanges: true,
    logLevel: 'info',
    proxy: '127.0.0.1:8010',
    port: 3000,
    open: true,
    notify: true,
    snippetOptions: {
      ignorePaths: ["panel/**"]
    }
  });
});

gulp.task('dev', ['browserSync'], function() {
  gulp.watch('./kirby/site/**/*.php', ['watch-php']);
  gulp.watch('./kirby/content/**/*.txt', ['watch-txt']);
});

AFAIK gulp-util is deprecated in gulp 4. I had to remove it from my config to get it to work.

It might be this too? More info: https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5


Edit: I’ve read too quick. You’re still on gulp 3.9…
I’ve encountered lots of issues with file system changes with gulp 3 (due to chokidar IIRC). I’ve switched to 4 a while back and I like it better.

I suspect that this error is from Gaze, which is used by Gulp Watch to keep watch on the files. I’ve seen this a few times, it’s one of the reasons I gave up on Gulp (I use it for more then Kirby). I think it doesn’t like the Glob changing so radically when the draft gets published. Basically it thinks the _drafts folder should still exist i think, because it was in the glob, and it’s not cooping with it disappearing.

Is that all your using Gulp for, is that your entire Gulp file? personally I switched to Laraval Mix and NPM scripts like this or this one I put together for my SASS framework.

Hi bvdputte and jimbobrjames!

Thanx for your answers.

bvdputte, i see… it think i need to switch to gulp ver. 4.
Is your gulpfile (ver. 4) publicly available?

jimbobrjames, yep it is a gaze - error.
no… i have a lot more gulp - tasks running… this is just a excerpt of the gulpfile.js - content.
thanx for linking your solution.

Saludos, Funkybrotha

No worries. I basically swapped out 1,200+ lines of Gulp tasks for about 20 lines of NPM scripts that did exactly the same thing, without Gulp. :slight_smile:

Hey jimbobrjames

…and now i’m reading… reading… and reading
about Laravel Mix!

You know i’m a music producer… so… if the
Mix sounds right i’m happy! :wink:

Do you know if it is possible to
watch PHP and TXT Files with Laravel Mix?

Saludos, Funkybrotha

Yep it totally is :slight_smile: Here my current setup I use with all my Kirby site builds. Uses Mix and you get easy deployments thrown in… I built it to work with my sass framework, but it will work with anything. Easy to tweak. Just put Kirby in the public folder.

The file watching is done in webpack.mix.js just change the rule on line 17 to suit you.

For a Kirby site, mine looks like this…

mix.browserSync({
  proxy: 'http://domain.test',
  files: [
    "public/assets/js/**/*.js",
    "public/assets/css/**/*.css",
    "public/site/templates/*.php",
    "public/site/snippets/**/*.php",
    "public/content/**/*.txt"
  ],
  notify: false
})
1 Like

Hi jimbobrjames

Thanx a lot!

Saludos, Funkybrotha