Comments (8)
nice, have a look at this PR: #78
from fastify-vite.
Upgrading to 3.0.0-beta.21 worked for me. Thanks for the quick fix.
from fastify-vite.
New version does hmr, just tested it with React
from fastify-vite.
I get this with Vue ReferenceError: __VUE_HMR_RUNTIME__ is not defined
from fastify-vite.
I think the vite config is not properly passed trough so it's always building for prod,
here is my patch that made hmr work (in react):
fastify-vite+3.0.0-beta.20.patch.zip
you can use patch-package
and drop this file into a patches
folder in the root
diff --git a/node_modules/fastify-vite/config.js b/node_modules/fastify-vite/config.js
index 55bfdde..152c913 100644
--- a/node_modules/fastify-vite/config.js
+++ b/node_modules/fastify-vite/config.js
@@ -3,6 +3,7 @@ const { fileURLToPath } = require('url')
const { dirname, join, resolve, exists, stat, read } = require('./ioutils')
const { createHtmlTemplateFunction } = require('./html')
+
const DefaultConfig = {
// Whether or not to enable Vite's Dev Server
dev: process.argv.includes('--dev'),
@@ -80,19 +81,21 @@ const DefaultConfig = {
return (error, req, reply) => {
if (config.dev) {
console.error(error)
+ scope.vite.devServer.ssrFixStacktrace(error)
}
- scope.vite.devServer.ssrFixStacktrace(error)
scope.errorHandler(error, req, reply)
}
},
}
async function configure (options = {}) {
- const defaultConfig = Object.create(DefaultConfig)
+ const defaultConfig = {...DefaultConfig}
const root = resolveRoot(options.root)
- const [vite, viteConfig] = await resolveViteConfig(root)
+ const dev = typeof options.dev === 'boolean' ? options.dev : defaultConfig.dev;
+
+ const [vite, viteConfig] = await resolveViteConfig(root, dev)
const clientModule = defaultConfig.clientModule ?? resolveClientModule(vite.root)
- const bundle = await resolveBundle({ ...options, vite })
+ const bundle = await resolveBundle({ dev, vite })
const config = Object.assign(defaultConfig, {
...options,
vite,
@@ -136,12 +139,12 @@ function resolveRoot (root) {
}
}
-async function resolveViteConfig (root) {
+async function resolveViteConfig (root, dev) {
for (const ext of ['js', 'mjs', 'ts', 'cjs']) {
const configFile = join(root, `vite.config.${ext}`)
if (exists(configFile)) {
return [
- await resolveConfig({ configFile }, 'build', 'production'),
+ await resolveConfig({ configFile }, 'build', dev ? 'development' : 'production'),
configFile,
]
}
from fastify-vite.
@galvez let me know if you would like a PR with those changes
from fastify-vite.
@sync Oh, that is a good catch! Would love a PR, for sure!
from fastify-vite.
Closed via #78
from fastify-vite.
Related Issues (20)
- Error on Windows: TypeError: Cannot read properties of null (reading 'replace')
- Websocket can not connect when using https fastify
- If vites config contains `defineConfig` with callback, then SSR is broken HOT 3
- How to configure multi-page entry HOT 8
- Issues running with fastify-compress HOT 4
- Serve static assets from ssr builds in production mode HOT 2
- TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string
- Trace: The CJS build of Vite's Node API is deprecated
- Conflicting websockets between vite and `@fastify/websocket` causing infinite redirects HOT 1
- [react][windows] React Starter Template does not start on Windows HOT 4
- How to use Vue plugins like instance.use(...) HOT 4
- NPM install fails with 'edgesout' error HOT 3
- [SPA] allowing passing additional context to the render function HOT 3
- mts file extension is not supported for vite.config HOT 3
- @fastify/vue Smart Import doesn't resolve path in windows HOT 6
- How to config fastify-vite in a Electron Vite project HOT 1
- Route path resolution of starters/react-base not working in Windows HOT 1
- Unable to build project and missing files HOT 1
- Unable to specify any base route other than '/' HOT 1
- Should not need to resolveViteConfig in production mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-vite.