Adding JS libraries in Laravel

by John H
~1 minute

Adding a library in Laravel

To add with npm the library needs to be included and compiled with Webpack

 

Here is an example with Moment.js

get the package (this will put in a dependency in package.json)
npm install moment

install
npm install

call it in the laravel mix
/resources/js/app.js
moment = require('moment');

compile it for the env
npm run dev
or
npm run production

 

More info about mix

https://laravel.com/docs/5.8/mix

Related Articles

Get Url In Laravel

There are a bunch of ways to grab the url in Laravel. Here are a few of the ways I have found....

John H John H
~1 minute

Storing and sorting Values in PHP Array

I just had a huge ordeal dealing with an array.  I needed to loop through an array - process some...

John H John H
2 minutes

Blocking Access to a Url route in Apache

This serves a 403 forbidden for any route with blog. RewriteRule ^(.*/)?blog(.*/)?/ - [F,L]...

John H John H
~1 minute