Search code examples
htmlnpmpathbundling-and-minificationparceljs

deploying problem with multiple html files. Parcel


when I deploy a website( with multiple entry points, many HTML files ) and the host uses the build command: parcel build index.html aboutme.html. the website deployed give me a 404 error. But if I write in the URL /aboutme.html or /index.html it goes... it's like a routeing problem.

HTTP://localhost:1234 => 404 error,
HTTP://localhost:1234/aboutme.html => it goes.

with 1 entry point, it goes all right, but I want multiple HTML files.

I've searched online commands like:

"build:client": "parcel build client/index.html --out-dir dist/client",

or

 "build:server": "parcel build server/index.js --target node --out-dir dist/server",

or even more with this weird flag command: --watch


Solution

  • all you need to do for client part:

    npx parcel build ./*.html
    

    that will put result to ./dist directory

    if you want now to serve the result on parcel dev server then do:

    npx parcel ./*.html
    

    the both urls will work

    http://localhost:1234/ - will open you index

    http://localhost:1234/aboutme.html - will open you 'about me'

    And - if you modify index.html (in root dir, not in dist) - changes will be automatically pulled to your browser.