Adding JS libraries in Laravel

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

npm install

call it in the laravel mix
moment = require(‘moment’);

compile it for the env
npm run dev
npm run production


More info about mix

You may also like...