Sunday 13 August 2017

How to bundle a Web project server side written in Node.js for production?

I know how to use webpack for production but that's only for client side. I used to deploy my simple project to pm2 but that project has only one single server.js file. Now the server side code consists of multiple files in different locations/folders, how can I bundle them for production?I have tried writing scripts in package.json. But I am stuck when using babel for bundling. My project is written in ES6. So I think I need to use babel to bundle the files.I have a few questions for now:Can babel cli bundle different files from different locations? (Some in project root, some in server folder).Can I just use the server.js file which is the entrance of my project for production? ( I use node server.js in development, actually I just run yarn start)Where should I put the production files? Currently I put it in a sub-folder called "lib" of the "dist" folder which also contains the client files.Is there a better way to do this for production?

Submitted August 14, 2017 at 06:51AM by caymanbruce

No comments:

Post a Comment