As Materio announced it's migrating from Webpack to Vite.
Please follow documentation for Migrating Your Laravel Project to the Latest Version
Once you migrated template to Latest Laravel version, please follow steps below:
Copy vite.config.js
file from Vite root folder to your Mix root folder.
Copy postcss.config.js
file from Vite root folder to your Mix root folder.
Replace package.json
file from Vite to Mix Project to update dependencies & devDependencies as per Vite.
Vite only supports ES modules, so if you are upgrading an existing application, you will need to replace any require()
statements with import
.
Now, you have downloaded vite integrated Materio template, so you can copy third-party libs that we have updated in the Vite package and replace with the mix onces.
You need to take care of the changes that you have customized for any assets.
You can find below listed base layout files from mix
package and replace it with latest vite
package files.
Find below files at resources\views\layouts\sections\
folder:
Also, update below file from:
Now, you need to replace mix()
with @vite
in your blade files.
When using Vite, you will need to use the @vite
Blade directive instead of the mix()
helper.
This will automatically detect whether you are running in serve or build mode and include all of the required <script>
and <link rel="stylesheet">
for you:
<script src="{{ asset(mix('assets/vendor/libs/jquery/jquery.js')) }}"></script>
<script src="{{ asset(mix('assets/vendor/libs/popper/popper.js')) }}"></script>
<script src="{{ asset(mix('assets/vendor/js/bootstrap.js')) }}"></script>
<link rel="stylesheet" href="{{ asset(mix('assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css')) }}" />
<link rel="stylesheet" href="{{ asset(mix('assets/vendor/libs/typeahead-js/typeahead.css')) }}" />
@vite([
'resources/assets/vendor/libs/jquery/jquery.js',
'resources/assets/vendor/libs/popper/popper.js',
'resources/assets/vendor/js/bootstrap.js',
'])
@vite([
'resources/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.scss',
'resources/assets/vendor/libs/typeahead-js/typeahead.scss'
])
You need to take care of the changes that you have customized for any assets.
You can find below listed base assets folders from mix
package and replace it with latest vite
package files.
resources\assets\
folder from Vite
to Mix
resources\js\app.js
file from Vite
to Mix
resources\css
folder from Vite
to Mix
public\assets\
folder:css\
js\
vendor\
public\assets\
You can find below listed files in Vite
and replace to your Mix
template at resources\assets\js
folder:
Replace .env
file from root folder of Vite to Mix
Finally, the Laravel Mix package and its Webpack dependencies can now be uninstalled:
npm remove laravel-mix resolve-url-loader
rm webpack.mix.js
/public/build
Finally, you can remove node_modules/
folder & composer.lock
files from your project.
You can use below command:
rm -rf node_modules/ composer.lock
Now, continue with the Laravel installation steps explained in the documentation