Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel elixir "gulp watch" doesn't watch for Javascript changes

I'm trying to use laravel elixir and it works fine.

gulpfile.js:

const elixir = require('laravel-elixir');

require('laravel-elixir-vue-2');

elixir(mix => {
    mix.sass('app.scss')
       .webpack('app.js');
});

But when I use gulp watch it watches only for scss files and not JS so if I edit app.js gulp just doesn't compile it however if I run gulp it compiles everythings it's just gulp watch that won't work properly.

like image 440
paolobasso Avatar asked Nov 10 '16 14:11

paolobasso


Video Answer


1 Answers

Maybe (but not sure) problem with webpack.

So try another way of bundling.

For example try this workaround:

elixir(function(mix) {
    mix.scripts(['app.js'], 'public/js/app.js');
       .sass('app.scss');
});

Also check terminal what it outputs, maybe some error happening when it tries to bundle app.js file.

If it will not work, so let's discuss it in comments, because Your problem requires debugging of watcher if it gets event that indicates file changed or not and so on...

maybe OS prevents changing of modification time.

there can be many why-s that prevents that


final recommendation is:

You have to debug "watch" task in gulp and check if it's getting file change event or not. So if NOT - write just Your own task that will check changes and run webpack.

like image 174
num8er Avatar answered Sep 20 '22 01:09

num8er