Graham Morby-Raybould

Designer. Developer. Freelancer.

Adding Boostrap.js to Laravel Project Via Gulp


Adding Boostrap.js to Laravel Project Via Gulp

So while on Twitch, streaming my current Laravel build I came up against something I have never thought about. How do I get Bootstrap.js from node modules into my Public JS folder without copy and pasting it in.

So to Gulp we go and for many this will be like I'm teaching you to suck eggs but for someone just starting out with Laravel and also Gulp its helps no end.

So the task here is to copy the JS script from one place to another in the same vain as when we gulp the sass files and compile. Laravel Elixir makes all these processes very easy with alot of things done for us out of the box.

So to the code! So by adding this through our Elixir function, Gulp grabs the file and places a nice little file into our destination.

 mix.copy(
        'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js',
        'public/js'
    );

So as we can see we call mix.copy followed by open and closing brackets and shut the line off. Then add the file path to whatever it is you want to copy over and after the comma, the destination. Then run Gulp and Hazzah! your file is in it's destination and you can go ahead and call it using a URL::asset or what ever way you see fit.

Again very simple but also very handy when you know how! 


Created: 2017-01-29.


Recent posts


Basic Laravel install

So you want to set up a new Laravel Install? Correct? Right ok so lets begin..... First...

2017-06-15

Read More

Back to blogging and a headache

It's a hard thing this day in age to decide what is best to do in terms of technology and how...

2017-05-23

Read More

Twitter