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.

noseratio
  • 59,932
  • 34
  • 208
  • 486

1 Answers1

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": []
}
noseratio
  • 59,932
  • 34
  • 208
  • 486
  • 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 – VINIT CHURI Nov 04 '21 at 08: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 Nov 11 '21 at 12:01