Include custom JavaScript in the app.js
Add your scripts under this path \resources\assets\js\
,
(ex : \resources\assets\js\scripts\my_script.js
& \resources\assets\js\another_script.js
)
And, add them to \resources\assets\js\app.js
require ('./scripts/my_script.js');require ('./another_script.js');
Just add your script in resources/assets/js
and then run gulp
to compile all your scripts into app.js
Check this for more info
I presume you have other files that are not exactly VueJs files and you want to build into a single script. In that case it is not good to put the script in that file. You can however place the files in your resources/assets/js
folder and add some code to your gulpfile.js
to build all your scripts into one file. Here is the code you might need to add.
mix.scripts([ 'filename.js', ]);
By default, the build file will be placed in public/js/all.js
.
You can customise that driectory by modifying the example above to something like this
mix.scripts([ 'filename.js], 'path/to/file.js');