This content originally appeared on DEV Community and was authored by KarenR
Have you guys experienced this issue before when using Vite? How did you resolved it?
I’m experiencing a different result using vite dev and vite preview for multi page site.
The vite dev works as expected when testing the development environment. But when running the preview, except for the /index page. the rest of the page have the correct url routing but the page displayed is still from the main.js (/index.html root).
I am using expressJS for my server side routing and vanilla JS.
I am following the vite documentation with folder/index.html for multi page site.
vite.config.js set up
resolve: {
alias: {
'@': resolve(dirname, 'src'),
},
},
build: {
base: '/src',
rollupOptions: {
input: {
main: resolve(dirname, 'index.html'),
about: resolve(dirname, 'src/about/index.html'),
fruits: resolve(dirname, 'src/fruits/index.html'),
404: resolve(__dirname, 'src/404.html')
},
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name]-[hash].js',
assetFileNames: '[name]-[hash].[ext]',
},
},
},
server: {
middlewareMode: true,
fs: {
allow: ['..'],
},
},
};
This content originally appeared on DEV Community and was authored by KarenR
KarenR | Sciencx (2024-07-22T08:55:13+00:00) Vite preview not displaying the correct page. Retrieved from https://www.scien.cx/2024/07/22/vite-preview-not-displaying-the-correct-page/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.