Minify and Bundle NodeJS Project

We did not find much information on this topic.

Is there any tool (gulp) for minimizing and combining a nodejs server project, including its node_module dependencies?

I have a scenario in which I cannot run npm installon a production computer, and I am limited to a maximum size of 20 MB.

+4
source share
2 answers

You should look into the shrinkwrap options as well as shrinkpack . This basically allows you to freeze the dependency versions GZips your node modules and simplifies their deployment. You may not need Gulp for this, and gzipping your packages is much more efficient than guessing it.

+2
source

pkg, npm

-

  1. npm install -g pkg

  2. bin.js.      , main.js/ ,

       const mainCode = require('.')
    
  3. "bin" "bin.js" json :

       {
          "name": "mainCode",
          "version": "1.0.0",
          "description": "web server app",
          "main": "main.js",
          "bin": "bin.js", 
          "author": "anybody",
          "license": "MIT"
        }
    
  4.     pkg -t node10-win .
    

, FYI -t - , , ( pkg --help )

node10 - ( node11 , )

https://github.com/zeit/pkg-fetch/releases

0

All Articles