javascriptwebmodulesnowpack

Snowpack 3.8 cannot find the source folder, running dev server with different root directory


I have a project structure like this:

enter image description here

When starting the dev server from root directory everything works perfectly. I would like my index.html file to be in the src directory, but then snowpack does not find the index.html file. When starting the snowpack dev server from inside the src directory it says it can not find the package.json file which is required.

Is there a possibility to start the snowpack dev server from my projects directory, but point to src as the root directory to be served?

I have tried the following configurations in snowpack.config.js

export default {
  root: "./src/index.html",
  mount: {
    src: "/src",
    public: "/",
  },
};
export default {
  mount: {
    public: { url: '/', static: true },
    src: { url: '/src' },
  },
};
export default {
  mount: {
    public: '/',
    src: '/src',
  },
};

Solution

  • If someone swing by having a similar problem, this link might help:

    frontend build config generator

    The generator created the following snowpack.config:

    {
      "mount": {
        "dist": "/",
        "src": "/"
      }
    }
    

    After applying this configuration, Snowpack should work as requested.