Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

keronbwan's avatar

Noob question: Laravel mix makes the javascript unusable

Hello there. I have

mix.js('resources/js/functions.js', 'public/js')

in my webpack file. Then in resources/js/functions.js I will have my javascript code. Weirdly enough, it is then put inside an anonymous function inside public/js which makes me not able to use it. It looks like this.

0 likes
1 reply
codegirl's avatar

hi , to add functions.js file to public/js folder , you just need to mention folder within public directory. Which in this case is js, so simply write :

mix.js('resources/js/function.js', 'js')

Please or to participate in this conversation.