-
Notifications
You must be signed in to change notification settings - Fork 4
Laravel Mix support
Tortue Torche edited this page Dec 13, 2017
·
15 revisions
If you don't want to use an asset pipeline package like Larasset you can use jQuery-Laravel with Elixir.
# Run theses commands in your Laravel root application:
php artisan vendor:publish --provider="Efficiently\JqueryLaravel\JqueryLaravelServiceProvider" --force
# Optional command: if you want to use the Turbolinks package (https://github.com/frenzyapp/turbolinks#readme)
php artisan vendor:publish --provider="Frenzy\Turbolinks\TurbolinksServiceProvider" --force
// Add this code in your webpack.mix.js:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.minify('public/js/app.js')
.version();
If you use Bootstrap, you should edit the resources/assets/js/bootstrap.js
, to comment or remove this line:
window.$ = window.jQuery = require('jquery');
Then edit the resources/assets/js/app.js
file, to replace the line require('./bootstrap');
by:
global.$ = global.jQuery = require('./jquery');
require('./turbolinks-jquery.js'); // Optional: if you want to use the Turbolinks package
require('./bootstrap');
require('./jquery_ujs');
require('./turbolinks.js'); // Optional: if you want to use the Turbolinks package
Finally, to compile the jQuery-Laravel scripts, run this Laravel Mix command:
npm run dev
Or for production (minify, versioning...):
npm run prod