webpacksnowpack

Can I enable directory listing in the Snowpack dev server?


I'm looking into using Snowpack as an alternative to Webpack. By default, if I run the webpack dev server (webpack serve) and no default document exists, browsing to http://localhost:8080 gives me a directory listing. I want to enable the same behaviour in Snowpack, but by default it's returning a 404 Not Found when I browse to /. Is there a config setting or a plugin I can use to enable directory browsing so it works in a similar way to Webpack?

screenshots of http://localhost:8080/ served by webpack serve and by snowpack dev


Solution

  • By default snowpack doesn't provide that kind of functionality out of the box. But that doesn't mean it's impossible.

    You could use express with snowpack server and fallback to serve-index if nothing is found.

    Basically you'll have to implement it yourself. But it's not that difficult