Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

#118 Switch to Vite #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
driesvints merged 3 commits into laravelio:main from thinkverse:bye-webpack-hi-vite
Sep 8, 2022
Merged

Conversation

@thinkverse
Copy link
Contributor

@thinkverse thinkverse commented Aug 31, 2022

This PR switches over from Laravel Mix to Vite. This PR also removes unused dependencies like lodash and axios to keep the bundle size down, due to loading all of highlight.js the bundle size is ~1000 KB, with gzip compression it's ~290 KB. Similar to the size Webpack produces, but slightly larger initial size. With the unused dependencies bundled I saw a build size of ~1025 KB and ~310 KB with gzip.

Solved the issue I mentioned about line numbers in #118 by moving the hljs import to the bootstrap.js file and then importing that into app.js, which fixes the issue of the line numbers plugin not finding hljs on the window object.

Looking forward to the review. 👍

Closes #118

Copy link
Member

Thanks @thinkverse! Bit short on time now but will give this a go soon.

thinkverse reacted with thumbs up emoji

Copy link
Member

I can't get the CSS to render. I keep on running into this with every project I migrate to Vite. Do you know what I need to do here?

Screenshot 2022年09月07日 at 14 28 00

Copy link
Contributor Author

I can't get the CSS to render

I've never had issues running npm run dev or npm run build and loading Vite assets with Valet or artisan serve. Are you using Sail or Docker? Could be that the port for Vite's dev server isn't open if it runs dev? 🤔

Copy link
Member

driesvints commented Sep 7, 2022
edited
Loading

Just artisan serve.

Copy link
Contributor Author

I just run the npm scripts in another terminal, I never had issues with that before. Is it a CORS issue, or does the browser block assets from different origins?

How I run Paste with artisan serve 1 .

Footnotes

  1. https://www.youtube.com/watch?v=NaavSjCScnU

Copy link
Contributor Author

thinkverse commented Sep 7, 2022
edited
Loading

@driesvints Looking at it again though, it seems the @vite directive isn't being interpreted by the Blade compiler since it prints out @vite([...]). Did you run composer install to install the updated dependencies?

I'm sure I updated both Composer files to require a version of Laravel where the Vite directive exists.

Copy link
Contributor Author

thinkverse commented Sep 7, 2022
edited
Loading

Yeah, I updated composer.json to use "laravel/framework": "^9.19", which is where the Vite directive was added1 . And composer.lock was updated using composer update --lock and that locked Laravel to the compatible version v9.27.0. 🤔

Footnotes

  1. Added Vite - https://github.com/laravel/framework/releases/tag/v9.19.0

Copy link
Member

It suddenly works for me 🤷‍♂️

Anyway, very much appreciated @thinkverse, thank you!

thinkverse reacted with rocket emoji

@driesvints driesvints merged commit fefb213 into laravelio:main Sep 8, 2022
Copy link
Contributor Author

It suddenly works for me 🤷‍♂️

Computer magic. 🧙‍♂️

driesvints reacted with laugh emoji

@thinkverse thinkverse deleted the bye-webpack-hi-vite branch September 8, 2022 07:17
Copy link
Member

I now have issues deploying this... can't figure out what's wrong...


> @ build /home/forge/paste.laravel.io/releases/20220908071709
> vite build
sh: 1: vite: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @ build: `vite build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/forge/.npm/_logs/2022-09-08T07_17_32_919Z-debug.log

Copy link
Member

Seems like vite itself was missing as a dependency. No idea how I ever got it to build locally 😅

Copy link
Contributor Author

How the heck did I miss that? 🤦‍♂️ I don't have Vite installed globally so I wonder how I also got it to build locally. That's a new one. 😂 Good catch. 👍

Copy link
Contributor Author

thinkverse commented Sep 8, 2022
edited
Loading

You know what. I've cracked it, laravel-vite-plugin has Vite as a development dependency so it'll be installed locally, but if you install for production those won't be installed, and since I forgot to add Vite as a dependency it was missing on the server and not locally. 🙂

Copy link
Member

Thanks for checking that 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Switch to Vite

AltStyle によって変換されたページ (->オリジナル) /