Understanding Laravel Mix Understanding Laravel Mix node.js node.js

Understanding Laravel Mix


You'll bundle up all your styles and scripts a single file each and serve them to the client minified.

For front end assets, call mix.sass('resources/assets/sass/app.scss'). In that entry point to your styles you will be able to import your other stylesheets as you need using Sass's @import 'about'; syntax. (Rename your other CSS files to end in .scss too).

For your back end assets, call mix.js('resources/assets/js/app.js'). Then, similarly you can import other JavaScript modules using import './about.js';. You may want to look up ES2015 modules so you can learn how to write modular JavaScript.

Read through the bootstrap.js file to see how Laravel hooks up jQuery and Vue by default. You don't need any of this, so remove whatever you don't want or delete the entire file if you don't need any of it.

Vue comes out of the box with Laravel but it's just a suggestion, you can replace it with your own front end framework of choice or rip it out and replace it with nothing. Up to you.

Edit: Long story short; use mix.sass and mix.js, read up on using Sass and ES2015 modules to write awesome code.