I have a simple app (no frameworks) bundled with Parcel that I want to serve with express. I have divided the app in three different subfolders "assets", "pages" and "admin" so I have a similar structure to this:
src
|
--assets
--admin
|
-- admin-folder
|
--index.html
--pages
|
--pages-folder
|
--index.html
Once the app is built and bundled with Parcel I want to serve both folders with two different express.static middlewares like:
app.use(express.static(path.join(__dirname, "dist", "pages"));
app.use("/admin", express.static(path.join(__dirname, "dist", "admin"));
I am not serving the whole "dist" folder because I wanted a cleaner URL without a "/pages" in the middle (eg. mywebsite.com/pages-folder and not mywebsite.com/pages/pages-folder) and because I can then authorize the access to the "/admin" part of the website. But, by doing so the bundle is broken since every reference (for example to the assets) is incorrect. How can I fix this issue?