Feature request to allow the user to add wildcard to JS files, such as:
mix.js('resources/assets/js/pages/*.js', 'public/js/pages')
You can do this with mix.scripts(), but for the main mix.js(), it's best to provide a single entry file.
mix.babel('resources/assets/js/pages/*.js', 'public/js/pages') still doesn't work..
scripts seems to only do ES5, so I need babel.
Also, what I was saying in the original post is:
Let's imagine this dir structure
resources/assets/js/pages
-> index.js
-> login.js
-> register.js
-> edit.js
Using this command: mix.js('resources/assets/js/pages/*.js', 'public/js/pages'), it should generate those files:
public/js/pages
-> index.js
-> login.js
-> register.js
-> edit.js
Is there anything right now that allows that?
Ah I misunderstood. mix.babel() will combine all of those files into, and apply Babel compilation.
mix.babel('resources/assets/js/pages/**/*.js', 'public/js/all.js');
In your case, either specify the files manually, or create a single entry point that requires all of those other pages.
Cool, thank you. Is there any plans in the future to allow what I described?
I don't think so.
+1 for this, pretty big
+1, would be very useful.
+1
+1
+1
+1
multiple output files would be really helpful for me.
I would like to include page specific scripts by using the following:
.babel('resources/assets/js/pagescripts/*.js', 'public/js/')
Ideally, this would generate multiple files using the names from the source files, then i could just add a script tag to any page that required any one script.
currently, we need to specify each script individually for transpiling through babel like:
.babel('resources/assets/js/pagescripts/asd.js', 'public/js/asd.js')
.babel('resources/assets/js/pagescripts/two.js', 'public/js/two.js')
.babel('resources/assets/js/pagescripts/another.js', 'public/js/another.js')
Allowing a simple one-for-one compilation with wildcards would be very beneficial when dealing with old projects. We compile each SASS file to a separate CSS file and merge them on a page-by-page basis on-the-fly. While I'd love to rewrite it all to be more modern, we don't have time for that.
But we also are moving to Mix, and the same codebase needs to be used by both systems as we migrate old code. It may seem like a bad practice, but it's the process we have. I imagine many other people are in the same boat and don't have the luxury to start from scratch. Please reconsider adding this.
+1
@penance316 Give this a try.
@priyankmaniar thanks for the link it worked great.
I sometimes forget that the build system is just JS code and we have the power to do things like this.
I would suggest others on this thread check the link mentioned.
+1
Would be really great to create all the bundles by one line.
There is still no updates on this issue?
Most helpful comment
+1 for this, pretty big