← ClaudeAtlas

laravel-mix-noteslisted

Laravel Mix 5 (^5.0.9) signature features and the webpack 4 era build traps. Use when editing webpack.mix.js, the resources/assets/ asset sources, or the package.json npm build scripts in a Laravel 5.4 / Mix 5 project, or diagnosing why a dev/watch/prod build fails on a newer Node. Covers the entry/output mapping, mix() versioning + manifest, the dev/watch/hot/prod script ladder, the Elixir heritage, and the legacy-OpenSSL flag. Not for application or Vue component logic — load when working on the asset pipeline itself or planning a Mix 5 → 6 upgrade.
hmj1026/dhpk · ★ 1 · Web & Frontend · score 72
Install: claude install-skill hmj1026/dhpk
# Laravel Mix 5 — webpack 4 wrapper Mix `^5.0.9` is the last 5.x line. It is a thin, opinionated wrapper over **webpack 4** that lives in `webpack.mix.js` at the project root. You describe entry/output pairs with a fluent API; Mix generates the webpack config underneath. > Era: Laravel 5.4, Vue `^2.5.17`, PHP `>=5.6.4`. Mix 5 pins > webpack 4 — it does **not** use webpack 5 or Vite. --- ## Signature features ### Entry / output mapping `webpack.mix.js` declares each compiled bundle as a source → output directory pair: ```js const mix = require('laravel-mix'); mix.js('resources/assets/js/app.js', 'public/js') .js('resources/assets/js/kds.js', 'public/js') .sass('resources/assets/sass/app.scss', 'public/css'); ``` `mix.js()` emits `public/js/app.js` and `public/js/kds.js`; `mix.sass()` compiles `app.scss` to `public/css/app.css`. The second argument is a directory (Mix keeps the source basename) — pass a file path to rename the output. `mix.js()` enables Vue SFC support and Babel transpilation out of the box for this era. ### Versioning and the manifest ```js mix.js('resources/assets/js/app.js', 'public/js') .version(); ``` `.version()` appends a content hash query string and writes `public/mix-manifest.json` mapping logical paths to hashed ones. In Blade, resolve the hashed asset with the `mix()` helper: ```blade <script src="{{ mix('/js/app.js') }}"></script> ``` This is the cache-busting mechanism — never hardcode the hash. Without `.version()`, `mix()`