Laravel Mix

Laravel Mix is a tool like Grunt, Gulp etc. It is created to compile assets and optimize assets in Laravel app. To make compiling assets easier Laravel Mix covers 80 percent of WebPack’s use case. It compiles, minifies and stores assets in the public folder.  First you need to install your node dependencies to Laravel project.

npm install

You need to know only about the resources folder and webpack.mix.js file in the project root where Laravel Mix does its job. Laravel Mix’s job is to compile all the assets in this folder and save them in public directory. In your terminal to see  how it works run the following command.

npm run dev

 The css and js folders in the public directory will be updated with the compiled code. Another benefit of Laravel Mix is its ability to minify the files and make it ready to deploy.

To watch assets for changes  run the command given below:

npm run watch