Open adgower opened 2 years ago
Can you paste here your normal webpack config and also your ssr webpack config?
Can you paste here your normal webpack config and also your ssr webpack config?
this is based upon new installation of laravel breeze with vue: webpack.mix.js
const mix = require("laravel-mix");
mix.js("resources/js/app.js", "public/js")
.vue()
.postCss("resources/css/app.css", "public/css", [
require("postcss-import"),
require("tailwindcss"),
require("autoprefixer"),
])
.webpackConfig(require("./webpack.config"))
.disableNotifications()
.version();
webpack.ssr.mix.js
const path = require("path");
const mix = require("laravel-mix");
const webpackNodeExternals = require("webpack-node-externals");
mix.options({ manifest: false })
.js("resources/js/ssr.js", "public/js")
.vue({ version: 3, options: { optimizeSSR: true } })
.alias({ "@": path.resolve("resources/js") })
.webpackConfig({
target: "node",
externals: [webpackNodeExternals()],
})
.version()
.disableNotifications();
Can you paste here your normal webpack config and also your ssr webpack config?
When I try and compile with ziggy imports I get:
Module not found: Error: Can't resolve './ziggy' in 'C:\Users\adgow\Documents\Sites\ssr5\resources\js'
import { createSSRApp, h } from "vue";
import { renderToString } from "@vue/server-renderer";
import { createInertiaApp } from "@inertiajs/inertia-vue3";
import createServer from "@inertiajs/server";
import { ZiggyVue } from "ziggy";
import { Ziggy } from "./ziggy";
createServer((page) =>
createInertiaApp({
page,
render: renderToString,
resolve: (name) => require(`./Pages/${name}`),
setup({ app, props, plugin }) {
return createSSRApp({
render: () => h(app, props),
})
.use(plugin)
.use(ZiggyVue, Ziggy)
.component("Link", Link)
.component("Head", Head);
},
})
);
I got it working by running:
php artisan ziggy:generate
then I got another error:
Starting SSR server on port 13714...
Inertia SSR server started.
ReferenceError: Link is not defined
at setup (C:\Users\adgow\Documents\Sites\ssr5\public\js\ssr.js:2828:132)
at C:\Users\adgow\Documents\Sites\ssr5\node_modules\@inertiajs\inertia-vue3\dist\index.js:1:9464
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Server.<anonymous> (C:\Users\adgow\Documents\Sites\ssr5\node_modules\@inertiajs\server\lib\index.js:46:37)
ReferenceError: Link is not defined
at setup (C:\Users\adgow\Documents\Sites\ssr5\public\js\ssr.js:2828:132)
at C:\Users\adgow\Documents\Sites\ssr5\node_modules\@inertiajs\inertia-vue3\dist\index.js:1:9464
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Server.<anonymous> (C:\Users\adgow\Documents\Sites\ssr5\node_modules\@inertiajs\server\lib\index.js:46:37)
You are not importing Link
and Head
import { createInertiaApp, Link, Head } from "@inertiajs/inertia-vue3";
How to fix this error?
ReferenceError: document is not defined
at insertStyleElement (/home/jack/code/inertia-ssr/public/js/ssr.js:2651:15)
at addStyle (/home/jack/code/inertia-ssr/public/js/ssr.js:2766:13)
at modulesToDom (/home/jack/code/inertia-ssr/public/js/ssr.js:2639:18)
at module.exports (/home/jack/code/inertia-ssr/public/js/ssr.js:2797:25)
at Module../node_modules/style-loader/dist/cjs.js!./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-18.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-18.use[2]!./node_modules/less-loader/dist/cjs.js!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/Pages/Layout/Header.vue?vue&type=style&index=0&id=b31d6d4e&scoped=true&lang=less (/home/jack/code/inertia-ssr/public/js/ssr.js:2514:120)
at __webpack_require__ (/home/jack/code/inertia-ssr/public/js/ssr.js:3379:42)
I found add
mix.vue({
...
useVueStyleLoader: true,
})
in webpack.ssr.config.js can fix this error !
After I run the node ssr.js script initial requests and on return this in the console
My inital setup is latest laravel, laravel breeze with vue. any tips on how to resolve this?