What's your package.json look like? maybe you need to npm update vue-loader
Inertia SSR compile issue with slot Element UI Plus
Stack
- Laravel 9
- Inertia & Inertia SSR
- Jetstream
- Vue 3 with composition Api
- Element plus UI
Issue
Hello everyone! I'm developing a new app to practice the SSR features in Inertia. Everything was going well until I wanted to get some things ready for production :/
The issue is that when I ran npm run prod it compiles my ssr.js
SSR
import { createSSRApp, h } from 'vue';
import { renderToString } from '@vue/server-renderer';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import createServer from '@inertiajs/server';
import route from 'ziggy';
const appName = 'Laravel';
createServer((page) =>
createInertiaApp({
page,
render: renderToString,
title: (title) => `${title} - ${appName}`,
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ app, props, plugin }) {
return createSSRApp({ render: () => h(app, props) })
.use(plugin)
.mixin({
methods: {
route: (name, params, absolute) => {
return route(name, params, absolute, {
...page.props.ziggy,
location: new URL(page.props.ziggy.url),
});
},
},
});
},
})
);
Webpack.ssr.mix.js
const mix = require('laravel-mix')
const webpackNodeExternals = require('webpack-node-externals')
mix
.js('resources/js/ssr.js', 'public/js')
.vue({
version: 3,
useVueStyleLoader: true,
options: {
optimizeSSR: true,
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('el-'),
},
},
})
.alias({
'@': 'resources/js',
ziggy: 'vendor/tightenco/ziggy/dist/index',
})
.webpackConfig({
target: 'node',
externals: [webpackNodeExternals()],
})
production": "mix --production --mix-config=webpack.ssr.mix.js && mix --production
and gives me the following error:
Module build failed (from ./node_modules/vue-loader/dist/templateLoader.js): TypeError: Cannot read property 'type' of undefined
I've found the issue and its because I'm using Element UI for my UI components. In this case, I'm using to view my data in a table format. The problem comes when I try to pass scoped data to a template
<el-table :data="artists" style="width: 100%" height="70vh" table-layout="auto">
<el-table-column prop="name" label="Name" />
<el-table-column prop="email" label="Email" />
<el-table-column prop="phone" label="Phone" />
<el-table-column align="right">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
</template>
</el-table-column>
</el-table>
Has anyone encountered this?
Please or to participate in this conversation.