klei/gulp-inject

how to add browserify with gulp-inject

zymr-keshav opened this issue · 0 comments

I have injected node_modules packages into my index.html. all files are adding but the content of the file has

    require('./angular');
    module.exports = angular;

now I read that browserify can do this require syntax to the original file content but did not get how and where to apply the browserify. tries with gulp-browesrify as well
there will be some way to add in transform property of gulp-inject but this does not work. here is the relevant code


var browserify = require('browserify');
var npmVendors = gulp.src(mainNPMFiles( {nodeModulesPath: '../node_modules/'} ));
  // .pipe($.babel({"presets": ["env"]}));

  var npmOptions = {
    relative: true,
    starttag: '<!-- inject:ang:{{ext}} -->',
    ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
    addRootSlash: false
    // transform: function (filePath, file) {
    //       return browserify(file);
    // }
  };

  return gulp.src(path.join(conf.paths.src, '/*.html'))
    .pipe($.inject(injectScripts, injectOptions))
    .pipe($.inject(injectVendor, vendorOptions))
    .pipe($.inject(npmVendors, npmOptions))
    .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
});

someone point out how to do this?

for more over this, you can find the issue on SO