Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Tabler in production

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

like image 683
user82395214 Avatar asked May 20 '19 23:05

user82395214


1 Answers

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

like image 107
user82395214 Avatar answered Nov 06 '22 20:11

user82395214