Repository navigation
Conversation
laravel-mix 6 pulls in webpack-dev-server 4 and node-libs-browser (elliptic via crypto-browserify), which account for the npm audit advisories that can't be fixed while we're on it. Switching to Vite 8 with laravel-vite-plugin removes them, and npm audit now reports 0. - vite.config.js builds resources/assets/sass/app.scss and a new resources/assets/js/index.js entry into public/build. `npm run dev` builds unminified output, which is committed as before. - index.js imports the existing plain scripts for their side effects in the same order mix concatenated them. The bundler wraps UMD libraries as CommonJS, so globals.js imports Sortable and Huebee and puts them on window. Huebee now comes from npm (2.0.x, same version as the vendored build) because the vendored packaged file requires ev-emitter/unipointer in its CommonJS branch. - postcss.config.js adds autoprefixer, which laravel-mix ran by default. - The bg1.jpg url() is now ../../img/bg1.jpg, relative to the built CSS in public/build/assets, and is marked external so Vite leaves it for the browser to resolve as processCssUrls: false did. - Both layouts use @Vite instead of mix()/asset(). - The package.json overrides are dropped; a fresh lockfile has no advisories without them.
laravel-mix ran Babel over the concatenated scripts. Vite's default target leaves newer syntax such as object spread in place, which would stop the whole bundle parsing on older browsers that still run module scripts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces laravel-mix 6 with Vite 8 and laravel-vite-plugin, which clears the 8 npm audit advisories left after #1620. They all came from laravel-mix's dependency tree (webpack-dev-server 4 / webpack-dev-middleware, and elliptic via node-libs-browser / crypto-browserify).
npm auditnow reports 0 vulnerabilities, with nooverridesneeded.What changed
vite.config.jsbuildsresources/assets/sass/app.scssand a newresources/assets/js/index.jsentry intopublic/build/.npm run devrunsvite build --mode development, which is unminified, and that output is committed as before.npm run prodgives a minified build,npm run watchrebuilds on change, andnpm run hotstarts the Vite dev server.index.jsimports the existing plain scripts for their side effects, in the same ordermix.babel()concatenated them. The scripts themselves are unchanged and still rely on globals (jQuery still loads frompublic/js/jquery.min.js).globals.jsimports Sortable and Huebee and assigns them towindow, and it runs before the other scripts. Huebee now comes from npm, pinned to~2.0.0to match the vendored build. The vendored packaged file can't be bundled because its CommonJS branch doesrequire("ev-emitter").build.targetises2015. laravel-mix ran Babel over the scripts, but Vite's default target would leave newer syntax untranspiled, for example the object spread inapp.js. Module scripts already need an ES2015 browser, so this is the lowest target that makes sense.postcss.config.jsadds autoprefixer, which laravel-mix ran by default.layouts/app.blade.phpandlayouts/users.blade.phpuse@vitefor the CSS and JS.webpack.mix.js,public/css/app.css,public/js/app.js, bothmix-manifest.jsonfiles and the vendoredhuebee.js.Behaviour notes
@viteemits<script type="module">, which is deferred and runs in strict mode. The app scripts now run after the rest of the page has parsed, including the inlinecustom_jsblock. The Blade inline scripts all wrap their code in$(function () {...}), which still runs after the bundle. If someone's custom JavaScript usesHuebeeorSortablestraight away, outside a ready handler, it would now run too early.public/build/assets/now, notpublic/css/. So thebg1.jpgurl()changed to../../img/bg1.jpg, and it's marked external so Vite leaves it for the browser to resolve. That matches whatprocessCssUrls: falsedid, and it keeps working for subfolder installs. One catch: undernpm run hot, the CSS is served from the Vite dev server, so the default background won't load there.@importandlighten()during the build. These are only warnings and the build still succeeds. I left them alone because fixing them is a separate change.CSS compared with the old public/css/app.css
lighten()results print asrgb(%)instead of hex. Newer Dart Sass writes colours this way, and they're the same colours.bg1.jpgpath changed, as described above.defaultsdata, not the older caniuse data the old build used. That drops-webkit-backdrop-filterand-webkit-clip-pathand adds-o-object-fit. Browsers that need the dropped prefixes, such as Safari before 18 for the blur, are below thedefaultsthreshold now.filter: progid:...values keep their single quotes, andhsla(0deg, ...)is written ashsla(0, ...). Both are formatting only.Testing
I ran all of the checks below again after the
/simplifyand/code-review --fixchanges.npm ci,npm run devandnpm run lint(all exit 0), thennpm audit(0 vulnerabilities)../vendor/bin/phpunit: 169 tests pass, 1 skipped./order, and the new order survives a reload./focuses search, and Enter opens the first matching tile./userselect(layouts/users.blade.php) renders with the Vite CSS.willReadFrequentlyperformance warning from huebee's own code.