arnoson / vite-plugin-live-reload

A simple live reloading plugin for vite.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What am I missing to get this working?

VaelVictus opened this issue · comments

I'm using CakePHP and I just want the page to update when I change my base.js or any .ctp (view) file. I've tried everything and confirmed that process.cwd() is the directory I expect, but the page is simply not refreshing on change.

I import as such: <script type="module" src="http://localhost:1337/js/base.js"></script>

Config:

import liveReload from 'vite-plugin-live-reload'

export default {
    server: {
        port: 1337
    },
    build: {
        manifest: true,
        rollupOptions: {
            output: {
                entryFileNames: `assets/[name].js`,
                chunkFileNames: `assets/[name].js`,
                assetFileNames: `assets/[name].[ext]`
            },
        },
    },
    plugins: [
        liveReload(['../View/**/*.ctp', '*.js', '*.ctp'], { alwaysReload: true,  root: process.cwd() }),
    ]
}

Unfortunately I can't reproduce your issue. I'm using a similar setup which works fine:

liveReload(
  [
    "./content/**/*",
    "./site/(templates|snippets|controllers|models)/**/*.php",
  ],
  { root: process.cwd() }
),

Are you using the latest version of the plugin and can you create a repository on github which demonstrates your issue?

No worries; as long as there's nothing obviously wrong with my implementation, I'll close the issue. The other live reload plugin didn't work either, so I have to assume it's some other misconfiguration on my end. Indeed I'm on the latest vite and live-reload versions. I'll let you know if I ever figure out what it is.