expressjs / serve-static

Serve static files
MIT License
1.39k stars 228 forks source link

Feature Request: Allow multiple roots #35

Closed jreichenberg closed 9 years ago

jreichenberg commented 9 years ago

It would be handy to enable a retry of relative paths against multiple roots before a 404.

Use case: when managing projects that rely on Bower for dependencies the paths to dependencies will differ when running from within the project itself (examples, tests, etc) vs. running 'downstream' as part of another project -- running from within the project the dependencies are nested within the project and running as a dependency downstream project dependencies will be siblings.

Related: The new "proxy" option in https://github.com/nodeapps/http-server#available-options

Somewhat similar to: https://github.com/gruntjs/grunt-contrib-less#paths and https://github.com/sass/node-sass#includepaths from the CSS compilation world --> allows a project to resolve relative @import paths against a known list of possible roots.

dougwilson commented 9 years ago

This "feature" already exists, as part of the larger Express ecosystem that this module is a part of. Example:

app.use(serveStatic(__dirname + '/some/dir'))
app.use(serveStatic(__dirname + '/some/fallback/dir'))

And so we'll see if the file is located in /some/dir first, and if not, look for the same file in /some/fallback/dir, and if not there, then 404.

If this is not what you're looking for, please follow up with some more concrete examples, since I followed the links, but I don't know enough about SASS/LESS to really understand what the options to those library mean.

jreichenberg commented 9 years ago

Didn't know this...that'll work. Thanks!

dougwilson commented 9 years ago

Gotcha. That means I need to add it to the documentation :)