Only serve ./dist folder


#1

Currently, bitcentivez (git) has the same problem as the original bitcentive, illustrated by this:

http://bitcentive.herokuapp.com/test/test.js

The web server is serving directories and files that should not be needed for the static site, which is built into ./dist. I would prefer if the server only served files in ./dist, but I am not sure if this is possible with the done-ssr and steal combination (ssr, in particular).

What configuration changes would be needed to make this work?

For instance, in my “bitcentivez” repo, done-ssr-middleware pulls the configuration for the static site from client/package.json, and therefore serves all of the client directory.

Similarly, steal relies on package.json for configuration.

Attempting to cp client/package.json client/dist/package.json and pointing done-ssr-middleware to client/dist/package.json doesn’t seem to work because there is an error about finding the built ./dist/<etc>/index.js.

It seems it is trying to resolve ./dist relative to an outer directory, assuming the site is built into ./dist/dist, and doesn’t understand or accept package.json being copied to ./dist.

I haven’t been able to find the relevant ssr code that would be causing this, however.

I’m assuming @matthewp might have some ideas in regards to this! :wave:

It might be something super simple. Thanks for any help. :pray:


#2

Why is that a problem?

Well, it’s not necessarily a “problem”, but I am very curious if it is possible, and I feel it should be allowed.

My curiousness stems from wanting to expand my understanding of the frameworks; the examples must be set up the way they are for a reason, and I need help to wrap my head around they are optimal.

If it’s possible, and I think theoretically it should be, I want to prove to myself that ssr sites can be hosted and served in production separate from the presence of directories or files in /client that are used for development (such as the node_modules directory).

I feel that it should be allowed if it is not already because, in my opinion, not serving unnecessary files is more correct, and this provides more encapsulation between development and production.

Is it allowed to serve just ./dist using the provided ssr libraries? Let me know if I’ve misunderstood.

If I’m wrong, please try and acknowledge the merits of my thoughts before questioning my thinking!

Just hoping for some external input to help influence and guide me in developing a solid starter repo.


#3

You can get an idea of what I’m on about in the OP from this commit that:

  1. Changes /dist/steal.production.js —> /steal.production.js.
  2. Adds && cp ./production.html ./package.json ./dist to the build npm run-script.
  3. Adds "client": "../../client/dist/" to the server/config/production.json.

(Actually, don’t need to copy ./production.html in No. 2 because of SSR…)