Build sapper project and run as daemon PM2

Deploying your sapper project

Once you pulled your sapper project to production server. Do the following steps

npm install
npm run build

After Running npm run build by default it will create all exported files in the folder

sapper/build .

You have to point your domain to this directory if you are using nginx or apache as webserver.

After doing this, You have to run the following command to listen to the sapper server to make sapper SSR working.

npx serve sapper/build

After running this it will usually listed to the port http://locahost:5000

To work your domian URLs well you have to add proxy_pass in you nginx config.

proxy_pass http://locahost:5000;

Now its good, and your sapper project will start working.

The last thing is, you need to add this sapper server listening process to PM2 to make the service will be running all the time as Daemon. You need to run the following command for it.

pm2 start 'npx serve -l 5000 build' --name blog

Enjoy!

  • Roopz © 2020