Error start. TypeError: liveReload is not a function
kviron opened this issue · comments
I am building a new project:
npm create vite@latest --template vanilia
The vite.config file.js
import liveReload from 'vite-plugin-live-reload'
export default {
plugins: [
liveReload('./**/*.php'),
]
}
I am executing the command of the npm run dev
I get an error:
failed to load config from D:\OpenServer\domains\sage.loc\html\app\themes\drozzi-theme\vite.config.js
error when starting dev server:
TypeError: liveReload is not a function
at file:///D:/OpenServer/domains/sage.loc/html/app/themes/drozzi-theme/vite.config.js?t=1657868630638:5:5
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async loadConfigFromFile (file:///D:/OpenServer/domains/sage.loc/html/app/themes/drozzi-theme/node_modules/vite/dist/node/chunks/dep-561c5231.js:62653:31)
at async resolveConfig (file:///D:/OpenServer/domains/sage.loc/html/app/themes/drozzi-theme/node_modules/vite/dist/node/chunks/dep-561c5231.js:62281:28)
at async createServer (file:///D:/OpenServer/domains/sage.loc/html/app/themes/drozzi-theme/node_modules/vite/dist/node/chunks/dep-561c5231.js:58899:20)
at async CAC.<anonymous> (file:///D:/OpenServer/domains/sage.loc/html/app/themes/drozzi-theme/node_modules/vite/dist/node/cli.js:699:24)
Happens to me as well.
Here's a workaround until this is fixed:
For JS:
// vite.config.js
import liveReload from 'vite-plugin-live-reload'
export default defineConfig({
plugins: [
liveReload.default(['...'])
]
})
for TS:
// vite.config.js
import liveReload from 'vite-plugin-live-reload'
type LiveReloadFixType = typeof liveReload
export default defineConfig({
plugins: [
((liveReload as any).default as LiveReloadFixType)(['...'])
]
})
Will look at this in the next days, thank you for reporting the issue!
I released a new version 3.0.0
that should fix this issue! Could you also test it and report if everyting is working as expected?
@arnoson I tested it right now, fixes the issue
Yes, the bug went away with version 3.0.0.
Everything is fine.
I wanted to ask. And it is possible to somehow connect the server proxying to a local domain, to develop a theme on a Wordpress cms.
I tried to use the server.proxy
setting but I couldn't do anything. The plugin shows changes to php files in the console, but does not update the page.
I couldn't configure it in any way, maybe you had experience using Vite + Wordpress Theme
I don't use Wordpress, but I use Vite together with Kirby CMS with a plugin.
I don't think you need to proxy anything, just make sure that the vite client script is included in your HTML/PHP file during development.