Laravel Asset Bundler

3.1.0 · active · verified Tue Apr 21

Laravel Bundler is a modern and fast asset building tool designed for the Laravel framework, serving as a direct alternative to Laravel Mix. It leverages Webpack 5 for bundling, Babel 7 for JavaScript transpilation, and esbuild for high-performance CSS and JavaScript minification. The current stable version is 3.1.0, with an active development cadence indicated by recent releases and continuous integration. Key differentiators include its focus on better defaults, explicit support for ESM via `.mjs` configuration files, and dedicated 'recipes' for integrating popular frontend frameworks like Vue.js (v2 and v3) with pre-configured loaders and plugins, including full HMR support. It generates a `mix-manifest.json` compatible with Laravel's `mix()` helper, ensuring a smooth transition for existing Laravel projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `laravel-bundler` for a Laravel project with Vue.js v2, including the necessary `webpack.config.mjs`, a basic `app.js` entry point, and essential `package.json` scripts and dev dependencies for a functional build process.

import webpack from 'webpack';
import { createConfig } from 'laravel-bundler';
import vue2Recipe from 'laravel-bundler/src/recipes/vue-2.js';

// webpack.config.mjs
export default createConfig({
    entry: {
        app: './resources/js/app.js'
    },
    plugins: [],
    // Other webpack configurations
},
vue2Recipe);

// resources/js/app.js
import Vue from 'vue';
import 'bootstrap/dist/css/bootstrap.css';
import RegularComponent from './components/Regular.vue';

new Vue({
    el: "#app",
    components: {
        RegularComponent
    }
});

// package.json (excerpt)
/*
{
    "type": "module",
    "scripts": {
        "dev": "webpack --config-node-env=development --progress",
        "prod": "webpack --config-node-env=production --progress"
    },
    "devDependencies": {
        "laravel-bundler": "^3",
        "webpack": "^5",
        "vue": "^2",
        "bootstrap": "^4",
        "@babel/preset-env": "^7",
        "vue-template-compiler": "^2"
    }
}
*/

view raw JSON →