Laravel elixir calling task according to watch expression
Asked Answered
S

2

10

Say we have this (simplified) elixir in gulpfile.js:

mix
.bower()
.less('test.less');

The problem is then whenever any file is changed, both bower and less tasks are executed.
Is there a way to only execute less when a file in a certain watch path has changed and only execute bower when for example the bower.json file has changed?

The real problem is that with other tasks, my watch process is becoming extremely slow and bower is running everytime I update a less file (which is irrelevant).

Thanks!

Subsidence answered 15/7, 2015 at 19:28 Comment(0)
S
1

As Jeffrey Way explained here

This is indeed a problem with the bower task. So I'm assuming it's also the case with imagemin.

I'll create a new task and open source it soon and update this answer.

Subsidence answered 26/7, 2015 at 18:9 Comment(0)
E
0

You can define another task handler to run the bower related tasks. The author in the following blog post have illustrated how you can do that. http://laravelcoding.com/blog/laravel-5-beauty-using-bower#09-gulp-bs

Personally I copy the required files from bower_components to assets directory with copy task, since i want my assets directory to have only the ones that I use.

So I have my definitions like

mix.copy('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js','public/assets/js/bootstrap-datepicker.min.js');
mix.copy('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css','public/assets/css/bootstrap-datepicker.min.css');
Eudoca answered 24/7, 2015 at 12:53 Comment(4)
Yeah but bower here is just an example.. if you had imagemin, it would do the same issue. It doesn't make sense to fire bower and imagemin everytime you change your less files. That's why I wanted to separate themSubsidence
Well I know your problem here is those tasks running in a situation which is not mandatory, and it seems not only one tasks all tasks get fired on a change ha? Check if its same after running npm updateEudoca
if those tasks are one time only, i would still recommend separating the tasks from elixir task.Eudoca
yes but I'm still looking for an automated solution.. when you're working in a team you want these to be automated.. bower.json is changed? okay recompile vendor.js and vendor.css (for example)Subsidence

© 2022 - 2024 — McMap. All rights reserved.