return src.pipe(through2.obj(function(file, _, next) {
    var b = bundleEntry(file.path)

    if (watch) {
      b.plugin('livereactload', {
        client: 'livereactload-chrome',
        port: hotreloadPort++
      })

      b.plugin(watchify).on('update', function() {
        log('Bundling %s', colors.magenta(file.relative))

        var contents = b.bundle()

        function swallow(err) {
          log(colors.red(err.message))
          log(err.stack)
          contents.unpipe()
        }

        function write(buffer) {
          endless.write(imitate(file, buffer))
        }

        contents.once('error', swallow).pipe(concat(write))
      })
    }

    var initialContents = b.bundle()
    next(null, imitate(file, initialContents))
  })).pipe(initial)
Ejemplo n.º 2
0
  return src.pipe(through2.obj(function(file, _, next) {
    let b = bundleEntry(file.path)
      , style = resolve(DEST, file.relative, '..', 'bundle.css')
      , appTransformDirs = [ resolve(file.path, '..') ]

    parcelify(b, { watch, bundles: { style }, appTransforms, appTransformDirs })
      .on('error', (err) => log(error('parcelify', err)))
      .once('done', () => touchp.sync(style))

    let bundler = watch ? watchify(b).on('update', () => {
      log('Bundling %s', colors.magenta(file.relative))

      let contents = bundler.bundle()
      let swallow = (err) => {
        log(colors.red(err.message))
        log(err.stack)
        contents.unpipe()
      }

      contents.once('error', swallow).pipe(concat(buffer => {
        endless.write(imitate(file, buffer))
      }))
    }) : b

    let initialContents = bundler.bundle()
    next(null, imitate(file, initialContents))
  })).pipe(initial)
 function write(buffer) {
   endless.write(imitate(file, buffer))
 }
Ejemplo n.º 4
0
 contents.once('error', swallow).pipe(concat(buffer => {
   endless.write(imitate(file, buffer))
 }))