Reputation: 18971
In a Laravel setup using Laravel mix, the mix.js(['resources/js/app.js','resources/js/new-offer.js'], 'public/js')
puts everything in one file, app.js
.
What I am trying to achieve is to have multiple .js
files each for one page. For example. I want to have index.js for my index.blade.php
and new-offer.js
for my new-offer.blade.php
etc ...
The idea is that each page is server side rendered and each page represents a static page comming fromm the server and each one should has it's own set of js files that works in. How this should be done, is it recommended, what are other arhcitectures ?
Upvotes: 0
Views: 445
Reputation: 2709
You can use multiple concatenated .js(...)
statements. In your case:
mix.js('resources/js/app.js','public/js').js('resources/js/new-offer.js' ,'public/js')
This will createapp.js
and new-offer.js
files in your public js folder
Upvotes: 3