buildify icon indicating copy to clipboard operation
buildify copied to clipboard

Support for filename patterns in concat

Open josdejong opened this issue 12 years ago • 4 comments

It would be very powerful when you could concatenate all files or a filtered set of files with buildify at once, something like:

var buildify = require('buildify');

buildify()
    .concat('./src/*.js')
    .wrap('../lib/template.js', { version: '1.0' })
    .save('../distribution/output.js')
    .uglify()
    .save('../distribution/output.min.js');

The functionality offered by the module fileset comes very close, though fileset works asynchronously.

josdejong avatar Jul 08 '13 14:07 josdejong

vote up hi josdejong, I have some files for example model/Player.js,model/Item.js. These files are pure js function (aka Class). Do you know any tool to concat these files under model folder and add a wrapper for each file to work with nodejs

vontio avatar Aug 02 '13 09:08 vontio

Well you could very easily combine node-fileset and buildify like:

var fileset = require('fileset'),
    buildify = require('buildify');

fileset('model/**/*.js', function(err, files) {
  buildify()
    .concat(files)
    .wrap('../lib/template.js', { version: '1.0' })
    .save('../distribution/output.js');
});

josdejong avatar Aug 02 '13 10:08 josdejong

Thanks josdejong

vontio avatar Aug 03 '13 03:08 vontio

I create a grunt plugin to do the work,someone may need it. https://github.com/vontio/grunt-autowrap

vontio avatar Aug 14 '13 08:08 vontio