Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include custom JavaScript in the app.js

I want to include a custom JavaScript in the app.js file which as the following code:

window.$ = window.jQuery = require('jquery')
require('bootstrap-sass');

The require only works for published packages and using node install but I want to know if there is a way to include a custom js in this file in order to have just one built script in my app (in this case the app.js script).

like image 240
Sergio Vilchis Avatar asked Sep 29 '16 19:09

Sergio Vilchis


People also ask

How do you add custom JS file in react JS?

Installation: Open a terminal inside your ReactJS project folder and write the following code to install react-script-tag Package. Import 'ScriptTag' component: Import the built-in 'ScriptTag' component from the react-script-tag library at the top of the file where we want to add the script tag.

What is App JS in JavaScript?

App. js is built to serve makers of static single-page apps. This means that it keeps all page navigation within the session of the webpage, defining "pages" as DOM nodes that can be instantiated.


1 Answers

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');
like image 67
amrography Avatar answered Oct 18 '22 17:10

amrography