0
Iβve managed to solve this with only vue.config.js
with the below. Iβve followed the approach from a previous answer of mine.
βββ src
β βββ assets
β β βββ logo.png
β βββ components
β β βββ HelloWorld.vue
β βββ pages
β βββ home
β β βββ App.vue
β β βββ cache.js
β β βββ main.js
β βββ 404
β β βββ App.vue
β β βββ main.js
βββ vue.config.js
And vue.config.js
:
module.exports = {
pages: {
index: {
entry: "./src/pages/home/main.js",
template: "public/index.html",
filename: "index.html",
title: "Home",
chunks: ["chunk-vendors", "chunk-common", "index"],
},
404: {
entry: "./src/pages/404/main.js",
template: "public/index.html",
filename: "404.html",
title: "404",
chunks: ["chunk-vendors", "chunk-common", "404"],
},
},
};
It goes without saying, but this only works in production as the routing is done by the web server. When you developed locally, check the 404 page by visiting the 404 page directly.
0
MPA is just a way to create multiple html files each with its own js bundle β essentially multiple independent Vue apps. As there is no router, there is no client-side routing and every request goes directly to the server. So the server is only place where you can detect the situation (unknown resource requested) and return custom 404 pageβ¦
Source:stackexchange.com