I have a folder inside my "assets" that contains multiple javascripts files. I have many folders in my assets, one for each purpose and all managed by Laravel Elixir with Gulp:
/assets
/css
/general
style.css
themes.css
/styles
products.css
single_item.css
customer.css
/js
/general
core.js
site.js
/scripts
products.js
single_item.js
customer.js
I already use "scripts" and "styles" plugin with Elixir in order to minify and combine all JS scripts from assets/js/general
and all CSS files from assets/css/general
into one single file inside /public/www/js/script.js
and /public/www/css/style.css
respectively.
Now what I need is having Elixir to minify every single file individually inside assets/js/scripts
and to put them all inside /public/www/js/scripts
without combining them into one single file. I also need the same for CSSs inside assets/css/styles
.
I could use "scripts" and "styles" specifying every single file manually, like that:
Elixir(function (mix) {
mix
.scripts([
'assets/js/scripts/products.js'
], 'public/manager/js/scripts/products.js')
.scripts([
'assets/js/scripts/single_item.js'
], 'public/manager/js/scripts/single_item.js')
/* ... and so on .... */
});
But let's say it would be frustrating...
I found a nice Gulp task here: https://github.com/gulpjs/gulp/blob/master/docs/recipes/running-task-steps-per-folder.md
It does the trick, even though it handles directories instead of files: it creates a minified version of all files contained in each directory, the result is as many minified files as the number of directories. I could put every file inside a directory. Anyway I wasn't able to create a new Elixir plugin inside /node_modules/laravel-elixir/tasks
that integrates that task (I'm very new to Elixir). I tried to paste that script inside my gulpfile.js after the Elixir definitions, but I found these problems (I renamed the task name to "scriptsfolder"):
gulp.task('default', ['scriptsfolder']);
ignores Elixir tasks;gulp.task('scriptsfolder');
runs Elixir tasks but not scriptsfolder;I really can't figure out how to integrate this behaviour.
Is there a way to integrate that script (or a better version that handles files instead of directories) into Elixir? Or is there a way to achieve my desired behaviour with Elixir? Of course I also need to be able to watch that process as well as I'm already doing with the other Elixir tasks.
Thank you.
Have you find a solution to your problem ? I'm exaclty in the same situation. Help welcome...
try this ;) https://gist.github.com/icfr/f30f0735ac2c7b276bc96c4d989b8e23
i use it in all my project
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community