Friday, 16 October 2020

How to copy "node_modules" using by "webpack-node-externals" to directory with production building?

Consider the full-stack application project with NodeJS back-end.

  • package.json includes dependencies for both front-end (like vue, vuex, etc.) and back-end (like body-parser, express, etc.).
  • The entry point for frontend (EntryPoint-FrontEnd.js) and entry point for backend (EntryPoint-BackEnd.js) are being built by different Webpack config; the main differences is usage of webpack-node-externals and target: "node" for back-end.
  • The dependencies for frontend are being bundled to EntryPoint-FrontEnd.js, but EntryPoint-BackEnd.js access to dependencies with webpack-node-externals.

enter image description here

Now: how to copy to 02-ProductionBuild only those dependencies, which using EntryPoint-BackEnd.js via webpack-node-externals?

enter image description here

I glad if can reach it by webpack-node-externals, but if impossible, other tools are welcome.

The basic practice is deploying the full project to host and installing dependencies by npm install. However all that we need for working application in server is 02-ProductionBuild folder including dependencies for EntryPoint-BackEnd.js.



from How to copy "node_modules" using by "webpack-node-externals" to directory with production building?

No comments:

Post a Comment