Dwight Watson's blog

Ignoring Moment.js Locales with Laravel Mix

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

Following up from an earlier post that described filtering out Moment.js locales with Rails Webpacker, here's how you can achieve the same thing using Laravel Mix. It's worth doing for the same reason - filtering out a heap of locales you're unlikely to use - and it works just the same.

Here's how you configure it in your webpack.mix.js file:

const webpack = require("webpack");
const { mix } = require("caravel-mix");

mix.webpackConfig({
plugins: [new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)],
});

// Configure your assets with Mix as per usual...

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.