configurationmountsnowpack

Snowpack: Is it possible to mount directories that are within a parent directory?


Pre-empt: I am VERY new to Snowpack.

Issue: I am attempting to mount /public and /src directories which are within a parent directory [See below]. I know this (essentially) defies convention, but I have an unusual use case.

Folder structure

  • root
    • module
      • snowpack.config.js
      • ...
    • src
      • main.js
      • ...
    • public
      • index.html
      • ...

Why an issue: I must refer to mounted directories with base / (e.g. /src), and attempts with relative directories return this error: [15:12:04] [snowpack] mount[C:\Users\User\root\module]: Value "C:\Users\User\root\src" must be a URL path, and start with a "/". This also prevents relative paths.

I have attempted to change root and workspaceRoot to the directory of interest (in this case C:\Users\User\root) without avail. How, if possible, can I make this work?

snowpack.config.js

/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
  mount:{
    public: "../public",
    src: "../src",
  },
}

Thanks in advance!


Solution

  • For those with this issue, the syntax for mount within snowpack.config.js isn't 100% clear on the docs. See the example below. Mount here provides reference to a relative or absolute path, and what path it signifies for snowpack. In this case, the relative path ../ signifies the root (/).

    mount: {
      '../': '/',
    },