Is there are gulp plugin that wire dependencies from yarn packages?

528 Views Asked by At

I am currently using asset-builder and wiredep to wire all my dependencies to my source file but I want to move away bower and use yarn instead. The two plugin I mention only support bower.

The problem I have with yarn is that all packages are installed in ./node_modules/ while bower has its own folder ./bower_components/.

1

There are 1 best solutions below

0
Alena Kastsiukavets On

I believe this should work for you:

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'));
});

gulp.task('todo', function() {
  return browserify('app/scripts/app.js')
    .external(dependencies)
    .bundle()
    .pipe(source('todo.bundle.js'))
    .pipe(map.write('./'))
    .pipe(gulp.dest(__dirname + '/public/scripts'));
});