#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Using Laravel Mix for Asset Compilation

Laravel Mix provides a clean, fluent API for defining webpack build steps, so compiling CSS and JavaScript doesn't require hand-writing complex webpack configuration.

Basic Setup

A typical webpack.mix.js file lives at the project root and defines what should be compiled.

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css');

Running the Build

npm run dev
npm run watch
npm run production

watch rebuilds automatically as files change during development; production minifies and optimizes output for deployment.

Versioning Assets

mix.js('resources/js/app.js', 'public/js')
   .version();
<script src="{{ mix('js/app.js') }}"></script>

version() appends a hash to filenames so browsers reliably fetch updated assets after a deploy, rather than serving a stale cached copy.

Note: newer Laravel versions default to Vite instead of Mix, though Mix remains supported for existing projects. With assets compiled, the next topic looks at pushing real-time updates from the server to the browser.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course