How to include node_modules in a separate browserify vendor bundle

前端 未结 3 698
我寻月下人不归
我寻月下人不归 2021-02-05 03:49

I am trying to convert an AngularJS app to use browserify. I have installed all my bower packages in node_modules using napa. Now I want to browserify them into a separate vendo

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-05 04:43

    This solution looks great:

    var packageJSON = require('./package.json');
    var dependencies = Object.keys(packageJSON && packageJSON.dependencies || {});
    
    gulp.task('vendor', function() {
       return browserify()
        .require(dependencies)
        .bundle()
        .pipe(source('vendor.bundle.js'))
        .pipe(gulp.dest(__dirname + '/public/scripts'));
    });
    

提交回复
热议问题