Reputation: 450
I'm using nodejs, express, jade, and less.
I route to a bunch of different subdomains (i.e. college1.domain.com, college2.domain.com). Each college gets a customized stylesheet. How can I be selective about which stylesheet to load?
I don't want to pass around a variable and decide when rendering the page which to load.
I would rather separate the stylesheets into different subdirectories and then tell the less-middleware to look at a specific directory based on the subdomain. Is this possible?
Upvotes: 1
Views: 155
Reputation: 3467
If your stylesheets are static files you could put nginx in front of your app server and let it serve the correct assets based on domain name and/or path (directly - not through your app). It might even be faster/better to let nginx do it since your app will have more resources to do app-stuff instead of serving assets.
Here's a sample configuration from the nginx documentation (slightly modified):
server {
location / {
proxy_pass http://localhost:8080;
}
location /stylesheets/ {
root /path/to/your/stylesheets;
}
}
This sends all requests to your app except those starting with /stylesheets/
which are fetched directly from the file system.
Check out the beginner's guide to nginx for more info.
Upvotes: 1