Ensure you have completed reading the simple Node Seed tutorial before reading this section.
If you are working on a backend for which Rubix does not provide an integration yet or you wish to build a static web site then distributables is suitable for you. So what exactly is a distributable? It is a self-contained, complete client-side app that is generated for you to use with your existing backend. However, distributables do not provide server-side rendering support.
Assuming you have cloned the
node-seed folder for your own project (let us called it
my-project), you can run:
$ cd /path/to/my-project $ npm run dist -s
to generate a distributable to your
my-project/dist folder. If you inspect the contents of
my-project/dist you'll notice that it has an
index.html with contents of the
public folder. You can then copy the contents of the dist folder to your own web server and serve the index.html file from there.
What if your project's static directory was located at:
/path/to/my/project/static? It would become cumbersome to manually copy the contents of the
dist folder every time you compile. So to fix that issue, you can pass in the path of your project's public/static folder as an environment variable. The NPM script will compile the assets to the static folder path instead. Here is an example:
$ DIST_PATH=/path/to/my/project/static npm run dist -s
But compiling for every change is itself painful. So we have built-in a watcher that watches for file changes and re-builds the distributable. Here is an example of how it can be achieved:
$ DIST_PATH=/path/to/my/project/static npm run dev:dist -s
For more NPM Launch Options (like running development server on remote instance, generating sourcemaps, generating production builds, testing, RTL support etc) click here: Launch Options