Vite config:
build: {
emptyOutDir: true,
outDir: './webroot/dist',
manifest: true,
rollupOptions: {
input: {
main: './webroot_src/main.ts',
},
},
},
Generated html:

The green scripts are inserted by the plugin, but the red above come from vite. Vite expects the outDir to be the root which is accessible by apache etc.
So there is no /dist prefix and dynamic modules cannot be loaded.
A solution would be to set outDir to ./webroot. But then, vite will remove all files in webroot if emptyOutDir is true.
Does anyone have an idea how to fix that? If not, emptyOutDir would not work if you have static assets in webroot that don't come from vite.
You would have to delete the /assets folder before building manually here and there (not a big deal though).
Vite config:
Generated html:

The green scripts are inserted by the plugin, but the red above come from vite. Vite expects the
outDirto be the root which is accessible by apache etc.So there is no
/distprefix and dynamic modules cannot be loaded.A solution would be to set
outDirto./webroot. But then, vite will remove all files inwebrootifemptyOutDiristrue.Does anyone have an idea how to fix that? If not,
emptyOutDirwould not work if you have static assets in webroot that don't come from vite.You would have to delete the
/assetsfolder before building manually here and there (not a big deal though).