I have tried using browserify etc... But they include browser specific code. I just want one javascript file to contain all my server side app.
I want to compile all the disparate sources of a server side node.js app into one file "app.js" so I can distribute it by itself and it contains all dependencies it requires inside the one file.
So if I had: one.js
require('./two.js')
two.js
console.log('two');
I'd run bundler one.js -o app.js
and app.js would look like:
console.log('two')
Ideally it would deal with the node system modules like fs, util, etc... intelligently. (I.e. probably not bundle them.)
Many nodejs modules require building or installation so you should consider distributing the node_modules folder or running npm install to install your app. If all the modules you use are simple js files with no further dependencies, I guess what you are looking for is to just merge the files together. You can easily do this with Gulp (and gulp-concat).
var gulp = require('gulp'),
concat = require('gulp-concat');
gulp.src(['imustbefirst.js', 'imustbesecond.js', '*.js'])
.pipe(concat('app.js'))
.pipe(gulp.dest('./'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With