Replace Laravel Mix with Vite #714
kresnasatya
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was curious how to replace Laravel Mix with Vite in Jigsaw because Vite become the modern tool to integrate frontend assets and backend (e.g. TailwindCSS). I check in this issue: #640 but no luck find the way. Luckily I find a reference to use Vite in Jigsaw: https://github.com/jasara/jigsaw-vite-vue-tailwind-template. In this discussion, I would like to give a brief steps how to replace Laravel Mix with Vite in Jigsaw.
vite.config.jsfile and code below. In short, this code create a plugin function namejigsaw(). This function acts as executor and watcher for files inside Jigsaw's project. If any file inside Jigsaw's project change then the watcher will trigger full-reload.config.phpaddviteUrlandviteClientUrlkeys.postcss.config.jsfile. In my opinion and intuition, this is necessary because Vite integrates with postcss. You just need to install postcss + postcss.config.js in order to make integration works. Link: https://vitejs.dev/config/shared-options#css-postcss<head>tag in order to make full reload works. I usesource/_layouts/main.blade.phpas a root view.scriptsinside package.json file. We set type module because we use ES6 import module invite.config.jsfile.{ "private": true, + "type": "module", "scripts": { - "dev": "mix" + "dev": "vite", - "production": "mix --production" + "production": "vite build" } }That's it! Try to run
npm run devandvendor/bin/jigsaw servein each terminal. Then, open your browser, edit a thing inside a file. Have fun! Thanks.Here's the full commit to see how to replace Laravel Mix with Vite in Jigsaw: phpbali-org/phpbali-org.github.io@1f20e7f
Beta Was this translation helpful? Give feedback.
All reactions