shama / webpack-stream

:tropical_drink: Run webpack through a stream interface
MIT License
1.39k stars 122 forks source link

Doesn't work with webpack-manifest-plugin / in-memory files don't make it to disk #161

Open nedtwigg opened 7 years ago

nedtwigg commented 7 years ago

webpack-manifest-plugin is a super simple plugin that creates a manifest.json in the root directory that maps from entry points to their hashed contents.

With webpack-stream, the manifest.json file is never created. Using a hint from #147, I figured out the problem was that the plugin is writing to an in-memory filesystem that never gets written to disk.

This was the workaround that I hacked together:

path = require('path')
fs = require('fs')
...
gulp.src(config.siteSrc)
    .pipe(webpack({
      config : require('./webpack.config.js')
    }, webpackCore, (err, stats) => {
      // write the in-memory manifest to disk
      const abspath = path.resolve(config.siteRoot + '/manifest.json')
      const content = stats.compilation.compiler.outputFileSystem.readFileSync(abspath)
      fs.writeFileSync(abspath, content)
      cb(err)
    }))
    .pipe(gulp.dest(config.siteRoot))

This works, but it seems like one heck of a hack. Is this a bug in webpack-manifest-plugin? Is there something webpack-stream could do to make this workaround easier to find / unnecessary?

LeonardMeagher2 commented 6 years ago

I imagine either webpack-manifest-plugin needs to add their file to the compilation.assets, OR webpack-stream needs to extract all files in it's memory-fs instance. I appreciate your hack though!