-
Notifications
You must be signed in to change notification settings - Fork 37
config to vite-plugin-ssr plugin #56
Comments
@hamedg68 , see my issue here, and then the pull request linked in it. You can manually make the simple change in your node_modules copy of the plugin, until @Seb-L Sebastian can get to updating it. My case is the same as yours -- problems coming in Vite SSR, which he probably didn't test originally as it occurs only in some circumstances. |
Also, here's another solution I just worked out, which uses Vite config. It's tricky and shouldn't be necessary, hence we need the simple fix of the pull request, but if this helps for the moment... Here's code, and then some explanation.
Now, to begin explanation and notes, I derived the method from something related: here, which now looks a little out of date. The link he gives to further source makes what he's done more clear. Node syntax has apparently kept changing, thus my form of import statement and just plain readFile. Depending on your situation, you might need to use require, where the statement is Or, though promises are 'better', it doesn't matter in this case of building with Vite, I think, so if this gives problems, you could just do what I first did, and remove the async, change the readFile to fs.readFileSync, and just import or require 'fs'. Now, I've put the actual fix into a function so it's easy and safe to use in a complex scenario where Vite config is entered dynamically. If you're just configuring Vite directly, you can simply take the {} object within the push call, and put that in your Vite config plugins array. It's a Vite plugin itself, has its name. Hope this helps, and for @Seb-L to see why it would be nice not to need it, all said with courtesy :) |
how add pinia-plugin-persist to vite-plugin-ssr plugin? it gives this error 'sessionStorage is not defined'
The text was updated successfully, but these errors were encountered: