Learn Laravel Mix

0
Level

Advanced

Language

Access

Paid

Certificate

Paid

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.

Add your review

Start Compiling Fast

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

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.

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.

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.

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.

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.

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.

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.

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.

Mix Extension Essentials

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.

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 together…in fifteen minutes!

User Reviews

0.0 out of 5
0
0
0
0
0
Write a review

There are no reviews yet.

Be the first to review “Learn Laravel Mix”

×

    Your Email (required)

    Report this page
    LiveTalent.org
    Logo
    LiveTalent.org
    Privacy Overview

    This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.