s2b / vite-asset-collector

Bundle your TYPO3 frontend assets with Vite
GNU General Public License v2.0
41 stars 12 forks source link

Hot reload also for html? #58

Closed JaccoBeech closed 4 months ago

JaccoBeech commented 4 months ago

Great extension, thanks!

Anyone has a tip to enable hotreload for html and php files?

I tried https://github.com/arnoson/vite-plugin-live-reload but didn't work

JaccoBeech commented 4 months ago

Aaah its working now. So cool, hotreload now too for html and php while developing. alwaysReload: true needed to be added.

import { defineConfig } from "vite"
import { dirname, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import autoOrigin from "vite-plugin-auto-origin"
import liveReload from 'vite-plugin-live-reload'

// TYPO3 root path (relative to this config file)
const VITE_TYPO3_ROOT = "./";

// Vite input files (relative to TYPO3 root path)
const VITE_ENTRYPOINTS = [
  "extensions/site_package/Resources/Private/Assets/Main.entry.js",
];

// Output path for generated assets
const VITE_OUTPUT_PATH = "Web/_assets/vite/";

const currentDir = dirname(fileURLToPath(import.meta.url));
const rootPath = resolve(currentDir, VITE_TYPO3_ROOT);
export default defineConfig({
  base: "",
  build: {
    manifest: true,
    rollupOptions: {
      input: VITE_ENTRYPOINTS.map(entry => resolve(rootPath, entry)),
    },
    outDir: resolve(rootPath, VITE_OUTPUT_PATH),
  },
  css: {
    devSourcemap: true,
  },
  plugins: [
    autoOrigin(),
    liveReload(['extensions/**/*.php', 'extensions/**/*.html'], { alwaysReload: true })
  ],
  publicDir: false,
});