Closed boeckMt closed 1 year ago
Probably this could be done with a new a middleware. Something like this:
const server = new Server({
port: 3000,
root: `${Deno.cwd()}/dist`,
});
server.use(staticFolder({
root: "/path/to/another/folder"
});
@boeckMt I have created this middleware. You can use it as following:
import lume from "lume/mod.ts";
import staticFolder from "https://raw.githubusercontent.com/lumeland/experimental-plugins/main/static_folder/mod.ts";
const site = lume({
server: {
middlewares: [
staticFolder({
root: Deno.cwd() + "/path/the/folder",
})
]
},
});
export default site;
Let me know if it works for you.
@oscarotero tanks for the fast response and creation of this middleware! It works perfectly :)
I'm currently trying to migrate a site from metalsmith which, by the way, works very well.
Great! I think this middleware may be useful to other users, so I'll move it to the official Lume repository.
Enter your suggestions in details:
It would be nice if a user could set the server
root
in the configuration Server options to serve static files that shouldn't be copied on every build.That could be done somewhere here https://github.com/lumeland/lume/blob/73200d261f3bda81c04fb820d71e118aaca8060a/cli/build.ts#L97
Another nice option would be to allow swapping the server instance e.g.
My use case is that I have many images that are in another directory and I don't want to copy them (like Copy static files) to the dist folder to prevent duplication and unnecessary work.
As a workaround I tried using a second server and redirects but unfortunately that don't work.