asset-rack icon indicating copy to clipboard operation
asset-rack copied to clipboard

StaticAssets should serve index.html at /

Open dankohn opened this issue 12 years ago • 1 comments

It would be nice to have a new option for StaticAssets called something like serveIndex that defaults to true. When true, it would automatically serve index.html when a browser requests /.

In the meantime, here is a workaround:

var rack = require ('asset-rack');
var fs = require('fs');

var assets = new rack.Rack([
    new rack.StaticAssets({
        urlPrefix: '/',
        dirname: __dirname + '/../../splash'
    }),
    new rack.Asset({
        url: '/',
        contents: fs.readFileSync(__dirname + '/../../splash/index.html').toString(),
        mimetype: 'text/html'
    }),
]);

dankohn avatar Jun 27 '13 14:06 dankohn

I like this idea, I've been doing something similar.

Although, I'd rather add this feature a little higher up, to the actual rack itself.

techpines avatar Jun 28 '13 01:06 techpines