seek-oss / sku

Front-end development toolkit

Home Page:https://seek-oss.github.io/sku

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: Serve sku-generated static files when server rendering locally

mengtzu opened this issue · comments

Summary

Static files (eg main.js, styles.css) generated into the specified dist folder should be served by the supplied express server without further configuration. This is a setting for development, not production builds.

Motivation

Without this, unless the appropriate express.static call is passed into middleware, requests for static files will fall into the render function fallback. In a typical case this would cause the app to return a rendered 404 html page instead of the js or css requested.

Detailed design

In config/server/server.js, after the express app is instantiated but before the render function fallback, we should include a line much like the following:

app.use(express.static(path.join(__dirname, './')));

How We Teach This

This should cause local server rendering to work as expected, and should not require teaching.

Drawbacks

This is not limited to sku-generated static files, if the server finds any others in its root it'll happily serve them too. That's still probably behaving as expected.

Alternatives

You can just pass this in manually as middleware, that just seems like an odd thing to require.

Unresolved questions

Is it worth creating a static folder for this purpose?

Implemented in #59