browserify / factor-bundle

factor browser-pack bundles into common shared bundles
Other
402 stars 27 forks source link

Failing when output folder does not exist #70

Closed albertorestifo closed 8 years ago

albertorestifo commented 9 years ago

I'm using Factor Bundle as part of a Gulp task, here is the task:

gulp.task('browserify', function() {

  return browserify({
        entries: [
          './app/js/utils/header.js',
          './app/js/pages/hub.js'
        ],
        debug: false,
        paths: ['./node_modules']
      })
      .plugin('factor-bundle', {outputs: [
        './public/js/utils/header.js',
        './public/js/pages/hub.js'
      ]})
      .bundle()
      .pipe(source('common.js'))
      .pipe(gulp.dest('./public/js'));
});

If I create the folders public/js/pages and public/js/utils it works fine, but when the folders do not exists I get the following error:

Error: ENOENT: no such file or directory, open './public/js/pages/hub.js'
grushetsky commented 8 years ago

I have the exact same issue.

zoubin commented 8 years ago

https://github.com/substack/factor-bundle/blob/master/index.js#L62 factor-bundle will not create intermediate directories for factor output streams.

I encountered the same issue, and worked out a way to make factor-bundle work with gulp more conveniently. See factor-vinylify.

ghost commented 8 years ago

I don't think it should be factor-bundle's job to make directories if they don't exist. Few other programs work that way and it's easy to add a call to fs.mkdir or mkdirp to prep a working directory.

grushetsky commented 8 years ago

@zoubin, thank you for help! factor-vinylify solves the problem. :+1: