Cara Merubah Vite Menjadi Mix | Replace Vite with Mix in Laravel 9.2

Soefyan Syah
Soefyan Syah11 Dec 2022
MixVite.js

Jika Anda memulai proyek Laravel 9.2 dan tidak ingin menggunakan Vite, Anda dapat dengan mudah menghapusnya dan kembali ke Laravel Mix.

Photo by <a href="https://unsplash.com/@afgprogrammer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Mohammad Rahmani</a> on <a href="https://unsplash.com/s/photos/laravel?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Cara Merubah Vite Menjadi Mix | Replace Vite with Mix in Laravel 9.2

Mulailah dengan menambahkan berikut ini ke direktori root proyek Anda webpack.mix.js

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .sourceMaps();

Kemudian ubah file package.json Anda:

Original

"scripts": {
    "dev": "vite",
    "build": "vite build"
},

Modified

"scripts": {
    "dev": "npm run development",
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "prod": "npm run production",
    "production": "mix --production"
},
"devDependencies": {
    "@popperjs/core": "^2.10.2",
    "axios": "^0.25",
    "bootstrap": "^5.1.3",
    "laravel-mix": "^6.0.6",
    "lodash": "^4.17.19",
    "postcss": "^8.1.14",
    "resolve-url-loader": "^5.0.0",
    "sass": "^1.32.11",
    "sass-loader": "^11.0.1"
}

Seharusnya begitu. Sekarang Anda dapat menjalankan npm run dev atau npm run development dll. untuk menggunakan Laravel Mix.

Soefyan Syah

Written by Soefyan Syah

Hey there! I hope you find this post useful. If you have anything to say, questions or feedback, send me a tweet or an email.