Add multiple dir for static files in Loopback

loopbackjs

Solution

Register `loopback.static` multiple times in `server.js`:

...
app.use(loopback.static(path.resolve(__dirname, '../client')));
app.use(loopback.static(path.resolve(__dirname, '../other-dir')));
...

The first one has highest precedence. See http://expressjs.com/api.html for more info.

You can do it with phases too, inside your `middleware.json` (See docs):

"files": {
    "loopback#static": [{
        "name": "client",
        "paths": ["/client"],
        "params": "$!../client"
    },
    {
        "name": "someother",
        "paths": ["/someother"],
        "params": "$!../someother"
    }]
}

Problem

Loopback has two areas where paths are set for static files: server.js ``` var path = require('path'); app.use(loopback.static(path.resolve(__dirname, '../client'))); ``` middleware.json ``` "files": { "loopback#static": { "params": "$!../client" } }, ``` In my dev environment I'd also like to reference another dir for example `/node_modules` How do I do this?

Original source