Laravel Mix is a build tool that provides an API for compiling, minifying, and optimizing frontend assets like JavaScript, CSS, and images. It is built on top of Webpack, offering a simplified configuration for Laravel projects.
Laravel Mix was introduced to make frontend asset management easier and more intuitive, particularly for developers unfamiliar with Webpack.
resources/js
and resources/css
folders structured for maintainability.Define your build steps in webpack.mix.js
:
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.version();
Run Mix to compile assets:
npm run dev # Development
npm run production # Production
This setup ensures that your frontend assets are ready for deployment.