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.
npm install laravel-bundlerVerified import paths — ran on the pinned version, not inferred.
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.
Uninstall `laravel-mix` (`npm uninstall laravel-mix`) and delete `webpack.mix.js`. Then, install `laravel-bundler` and create a `webpack.config.mjs`.
Upgrade your Node.js installation to version 20.14.0 or newer using a version manager like nvm or fnm.
Add `"type": "module"` to your `package.json` and rename your Webpack config file to `webpack.config.mjs`.
Consult the relevant recipe documentation and install all listed peer dependencies using `npm install --save-dev [package-name]`.
Ensure `webpack` is installed as a dev dependency: `npm install --save-dev webpack@^5`.
Rename your `webpack.config.js` to `webpack.config.mjs` and ensure `"type": "module"` is present in your `package.json`.
Install the required Vue version and its associated compiler: `npm install --save-dev vue@^2 vue-template-compiler@^2` (for Vue 2) or `npm install --save-dev vue@^3` (for Vue 3).