Vite preview not displaying the correct page

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. Bu…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Vite preview not displaying the correct page." KarenR | Sciencx - Monday July 22, 2024, https://www.scien.cx/2024/07/22/vite-preview-not-displaying-the-correct-page/
HARVARD
KarenR | Sciencx Monday July 22, 2024 » Vite preview not displaying the correct page., viewed ,<https://www.scien.cx/2024/07/22/vite-preview-not-displaying-the-correct-page/>
VANCOUVER
KarenR | Sciencx - » Vite preview not displaying the correct page. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/22/vite-preview-not-displaying-the-correct-page/
CHICAGO
" » Vite preview not displaying the correct page." KarenR | Sciencx - Accessed . https://www.scien.cx/2024/07/22/vite-preview-not-displaying-the-correct-page/
IEEE
" » Vite preview not displaying the correct page." KarenR | Sciencx [Online]. Available: https://www.scien.cx/2024/07/22/vite-preview-not-displaying-the-correct-page/. [Accessed: ]
rf:citation
» Vite preview not displaying the correct page | KarenR | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.