1

How to specify the public HTML folder while adding Snowpack to an existing Node.js project?

My existing project structure:

Root
|-src/
|-public/index.html

I've added Snowpack:

npm install --save-dev snowpack 

Then when running Snowpack dev server:

npx snowpack dev

I'm getting No webpage was found for the web address: http://localhost:8080/ in the browser.

I expected ./public/ to be the default web folder for Snowpack, but apparently it needs some configuration.

1 Answer 1

6

How to specify the public HTML folder while adding Snowpack to an existing Node.js project?
...
I'm getting No webpage was found for the web address: http://localhost:8080/ in the browser.

I'm new to Snowpack and I couldn't find an answer to this specific problem in the docs, so it took a bit of googling and experimenting. Answering to my future self:

If we create a blank Snowpack project from the template:

npx create-snowpack-app proj --template @snowpack/app-template-blank

then we'll get ./proj/snowpack.config.json, that's where we can set up or change the folder mapping, and we can copy this file to the Root of our existing project:

{
  "mount": {
    "public": "/",
    "src": "/_dist_"
  },
  "plugins": []
}
2
  • hi thanks for the Question and answer, I'm facing the same issue javascirpt npx create-snowpack-app proj --template @snowpack/app-template-blank by the way without doing the npx and cloning the black project the same snowpack.config.mjs settings doesn't work if I install the snowpack and specify the mount directory in the snowpack config, after running the project I get a 404 so for you too does it only work if you do the npx or does it work if you install the snowpack yourself and configure the snowpack to look into src directory Commented Nov 4, 2021 at 8:27
  • @VINITCHURI it's been a while since I dealt with it and I can't verify the behavior you're asking about, sorry.
    – noseratio
    Commented Nov 11, 2021 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.