On my local machine I have been developing on a tabler clone. To run it, I do as the repo suggests and run npm run serve
. This brings up nice dev tools like auto-compiling scss and livereloading after changes. Further, npm run dist
creates a /dist
folder with my sites contents. However, I want to run this on an EC2 instance, but am unsure how to run for a production environment. How would I do this?
A direct Tabler clone is live here on my server. As you can see it takes too long to serve up the basic index page. This is the issue I am trying to solve by running in production
My solution was to wrap the code in /dist
with a new node/express program. I set up a basic express app under /prod
. In app.js
I have the following code.
const dist = path.join(__dirname, '/public/');
router.get('/', function(req, res) {
res.sendFile(path.join(dist, '/index.html'));
});
For production, first I call npm run dist
Then I call npm run prod
which does the following: "prod": "del ./prod/public && move-cli --mkdirp ./dist/ ./prod/public"
Now the server is runnable using node prod/bin/www
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With