6

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.

paolobasso
  • 2,008
  • 12
  • 25
  • 4
    This seems to be an open issue: [https://github.com/laravel/elixir/issues/598](https://github.com/laravel/elixir/issues/598) – camelCase Nov 10 '16 at 16:06
  • 1
    Yes, I've found too something online but no answer, only questions. – paolobasso Nov 10 '16 at 16:17
  • 1
    @paolo.basso99 Currently the only solution is downgrading – manniL Nov 12 '16 at 18:34
  • 1
    @paolo.basso99 Can you add your full `gulpfile.js` file? – Gerard Reches Nov 15 '16 at 10:53
  • 1
    @GerardReches I've updated the answer. – paolobasso Nov 15 '16 at 12:44
  • 1
    @paolo.basso99 Can you change `mix =>` to `function(mix)` and try again? Shouldn't be this, but just in case... Webpack is working for me. I'm using this versions `"laravel-elixir": "^6.0.0-11", "laravel-elixir-vue-2": "^0.2.0", "laravel-elixir-webpack-official": "^1.0.2"`. There are other issues like I [posted in Laracasts](https://laracasts.com/discuss/channels/elixir/webpack-not-really-compiling-all-the-time-during-gulp-watch) days ago. I'm not sure if it's related with your issue. – Gerard Reches Nov 15 '16 at 12:53
  • 1
    I've already tried function(mix) but it does not works – paolobasso Nov 15 '16 at 13:05
  • Did you make any progress with this question? – dispake Mar 25 '17 at 09:32

1 Answers1

4

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.

num8er
  • 18,604
  • 3
  • 43
  • 57
  • 1
    Can i use function like require() using "mix.scripts()"? – paolobasso Nov 12 '16 at 18:57
  • 1
    Nope) cuz webpack compiles code to native "old-style" js. but if You know nodejs a bit You can write Your own watcher. – num8er Nov 12 '16 at 19:03
  • 1
    Actually I've never used node however I know pretty well Grunt and I could set the whole project to work with it instead of laravel elixir but I would prefer to fix webpack in order to use its cool stuffs – paolobasso Nov 12 '16 at 19:06
  • 1
    I had something alike on Windows OS + Laravel app in Docker container. I was changing file but watcher in container was not getting file change event because of Windows was setting modification date in NTFS, but in Docker was EXT3 so was incompatible to handle that event, so wrote custom watcher that was periodically walking predefined files and checking md5-sum. – num8er Nov 12 '16 at 19:09
  • 1
    if You know grunt, so use it, and handle file changes and run webpack on it. – num8er Nov 12 '16 at 19:17
  • Yes, I know but still I would know (for personal knowledge) how to fix laravel elixir (if it's possible). – paolobasso Nov 12 '16 at 19:38