Learn Laravel Mix

Webpack is the most powerful and flexible asset compilation tool available today. With that power, however, comes a certain level of complexity. That's where Laravel Mix steps in. Intended for the 80% usecase, Mix wraps around webpack to make most commonly desired build tasks a cinch to activate.

In this series, as the maintainer of Laravel Mix, I'll teach you everything you need to know - from the basics, to advanced configuration.

Start Series

Share this series on:

  • 01

    Episode 1 Run Time 7:28

    Start Compiling Fast Free

    Let's begin by installing the necessary dependencies, and compiling our JavaScript and Sass as quickly as possible, using Mix. It's easy!

  • 02

    Episode 2 Run Time 5:22

    Decoding Your NPM Scripts

    Out of the box, you'll notice that Laravel includes a number of helpful NPM scripts for triggering webpack. To start, the most relevant ones are dev, watch, and prod. In this lesson, we'll decode these commands to ensure that you fully understand exactly what you're triggering.

  • 03

    Episode 3 Run Time 12:46

    JavaScript Bundling

    The mix.js() command is your go-to method for any JavaScript bundling needs. This will take care of ES2017 compilation, tree shaking, minification, and more. Let's review everything you need to know in this episode.

  • 04

    Episode 4 Run Time 12:25

    The Ins and Outs of CSS Compilation

    Now that you understand how to compile your fancy, modern JavaScript, let's move on to CSS tooling. Whether you prefer Sass, Less, Stylus, or PostCSS, Mix has you covered.

  • 05

    Episode 5 Run Time 6:57

    Adding PostCSS Plugins

    PostCSS may be used standalone, or even as a secondary step after your core Sass/Less compilation. Either way, the end result will be the same. Think of PostCSS plugins as layers of an onion, so to speak. Each layer has the chance to operate upon your stylesheet, and modify it in some way. Once complete, those styles are then passed on to the next layer of the onion. Let's review this workflow, when using Laravel Mix.

  • 06

    Episode 6 Run Time 3:23

    Automatic Browser Refreshing

    Mix provides out-of-the-box support for Browsersync, which allows us to detect and refresh the browser each time a relevant asset of yours has changed. No longer will you have to manually refresh the browser over and over to review small, visual tweaks.

  • 07

    Episode 7 Run Time 4:51

    Cache-Busting Assets

    The `mix.version()` call will append a unique hash to each file within your generated `mix-manifest.json` file. This can be used to instruct your server when to "bust the cache," and fetch a new copy of the related asset.

  • 08

    Episode 8 Run Time 3:16

    Registering Additional Babel Plugins

    Behind the scenes, Laravel Mix leverages Babel's env preset, when transforming your code. However, from time to time, you may need to register additional plugins. Let's review exactly how to do so in this episode.

  • 09

    Episode 9 Run Time 7:09

    Async/Await Support Out of the Box

    Laravel Mix 1.7 and higher ships with async/await support out of the box. These two keywords simplify the process of working with promises in a more synchronous fashion.

  • 10

    Episode 10 Run Time 7:36

    Mix Extension Essentials Free

    Laravel Mix 2.1 and up includes support for custom user extensions. In fact, the very components that Mix uses behind the scenes are constructed in the exact same way. In this episode, we'll learn the basics of the API. You'll see that there are two ways, based on the complexity of your new component, to extend Mix.

  • 11

    Episode 11 Run Time 14:34

    Build and Deploy a Mix Extension in 15 Minutes

    Now that you understand the basic API for constructing Mix extensions, let's build and deploy a real-life extension through npm fifteen minute!

You May Also Enjoy...

Here are some additional series that may be up your alley.