https://blog.yuyansoftware.com.tw/2022/12/laravel-vite/
按照laravel 文檔Installing Laravel Breeze 操作時怔球,會遇到各種問題,這里簡單做下總結(jié)
使用mix打包
- 創(chuàng)建database.sqlite
cd database
sqlite3
.open database.sqlite
- 修改 resources/views/app.blade.php
<!-- @vite('resources/js/app.js') -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<script src="{{ asset('js/app.js') }}" defer></script>
- 修改 webpack.mix.js
const mix = require('laravel-mix');
const path = require('path');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.webpackConfig({resolve: {alias: {'@': path.resolve(__dirname, 'resources/js/')}}})
.vue()
.postCss('resources/css/app.css', 'public/css', [
//
]);
添加了webpackConfig() 和 vue()的調(diào)用苟弛,以及const path = require('path');
- 修改 resources/js/app.js
//注釋掉這個引用
// import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
//下面的代碼需要修改下
createInertiaApp({
title: (title) => `${title} - ${appName}`,
//注釋掉這句
// resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
//添加這句
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
.mount(el);
},
});
修改好后運行完 npm run dev,就可以看到登錄和注冊入口了
使用vite打包
- 創(chuàng)建database.sqlite
cd database
sqlite3
.open database.sqlite
注意升級php版本叛拷,越新