A little late, but I hope that he is still helping someone (for example, to himself, who got here from a Google search for "prepublish").
I find uglifyjs one of the most popular miniaturization and compression tools.
You can use it as follows:
"scripts" : { "prepublish" : "./node_modules/.bin/uglifyjs -o myfile.min.js myfile.js" }
Just add uglify-js to your devDependencies .
See uglifyjs options and more on how this works. If the minimization process becomes too complicated, you can create a Makefile and use something like:
"scripts" : { "prepublish" : "make minify" }
source share