In my Laravel project I have a number of javascript files and a number of coffeescript files. They're stored in the following structure:
resources/assets/js/jquery.min.js
resources/assets/js/jquery.form.js
resources/assets/coffee/main.coffee
What I would like to do using Laravel Elixir and Gulp, is to compile the coffeescript file into Javascript, and combine all 3 Javascript files into a single file and output it:
public/js/main.js
My problem seems to be that mix.scripts()
only likes javascript files whereas mix.coffee()
only seems to like coffeescript files, so I'm finding it difficult getting the output I need.
I'm sure I could achieve this in a "hacky" way by running mix.coffee()
on my coffeescript and then running mix.scripts()
on the resulting file and the other two Javascript files but I was hoping there would be a better way to achieve this.
elixir(function(mix) {
mix.scripts([
'jquery.min.js', 'jquery.form.js'
], 'public/js/main1.js');
mix.coffee([
'main.coffee'
], 'public/js/main2.js');
});
mix.coffee()
and then either usingmix.scripts()
ormix.combine()
to build a single file after it. He said Elixir runs synchronously so it should be okay to do it that way. Not an ideal solution but it works I suppose! – Jonathon Dec 17 '15 at 12:51