Does a tool that concats, builds, and minifies your Node.js app into a single file exist?

Say I have a server-side app that I want to "publish" in a "compiled" version. For Node.js, that would be:

  • Concatenating the files together to obfuscate code structure
  • Minifying to obfuscate code

Complications:

  • CommonJS framework with requires - need to resolve paths
  • 3rd party dependencies in node_modules - don't concatenate these
  • "Assets" or basically any files that are not required - need some sort of roster

Does such a tool exist? Do you have recommendations on how to implement one?

Untested, but seems to be what you're after.

https://www.npmjs.com/package/node-uglifier

You could then go

var nodeUglifier = require("node-uglifier");

new NodeUglifier("lib_compiled/test/testproject/main.js")).uglify().exportToFile("lib_compiled/test/resultFiles/simpleMergeAndUglify.js";