You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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?
The text was updated successfully, but these errors were encountered:
markdalgleish
changed the title
RFC: serve sku-generated static files when server rendering locally
RFC: Serve sku-generated static files when server rendering locally
Sep 5, 2017
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?The text was updated successfully, but these errors were encountered: