Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Multi-compiler mode #19

Open
RyanS opened this issue Apr 4, 2016 · 4 comments
Open

Multi-compiler mode #19

RyanS opened this issue Apr 4, 2016 · 4 comments

Comments

@RyanS
Copy link

RyanS commented Apr 4, 2016

This may very well be an issue with webpack and not webpack rails but when using multi compiler mode (https://github.com/webpack/webpack/tree/master/examples/multi-compiler) the manifest that rails reads gets overwritten by each "compile target" so only one package is available in the manifest.

Any way to have both in the manifest? There seems to be a mention of it here: https://www.npmjs.com/package/webpack-manifest-plugin but I have no idea what "pass a shared {} to cache option" really means

@RyanS
Copy link
Author

RyanS commented Apr 5, 2016

Aright so it seems that the deal is with the stats-webpack-plugin that the gem relies on to create the manifest file. It has no way to merge both compiles from a multi compile setup. I guess a solution would be allow the gem to read from multiple manifest files and merge them internally.

Unless I am missing some functionality that webpack can provide

@hovissimo
Copy link

Not related to the stats plugin, but webpack/webpack-dev-server#641 is also an issue with webpack-rails in multi-compiler mode.

@rhys-vdw
Copy link

rhys-vdw commented Mar 1, 2017

Relevant issue unindented/stats-webpack-plugin#13.

I wonder if it might be sufficient to simply switch dependency to webpack-manifest-plugin. It seems to just output the content of stats-webpack-plugin's assetsByChunkName (asset name key to output file value hash). Although it looks like it can be configured so that the other information (publicPath) etc. can be prepended to the output file paths.

So, something like this:

stats-webpack-plugin's manifest:

{
  errors: [/*...*/],
  warnings: [/*...*/],
  version: '<some-version>',
  hash: '<some-hash>',
  publicPath: 'localhost:3000/assets',
  assetsByChunkName: {
    main: 'main.js',
    admin: 'admin.js'
  },
  assets: [{ name: 'main.js', size: 234 }, { name: 'admin.js', size: 234 }],
  chunks: [/*...*/],
  chunkNames: [/*...*/],
  children: [/*...*/]
}

webpack-manifest-plugin's manifest:

{
  main: 'localhost:3000/assets/main.js',
  admin: 'localhost:3000/assets/admin.js'
}

So provided all we care about is publicPath and actual mapping of asset to public filename this should be fine. And as @RyanS pointed out, there is support for a shared cache object.

@rhys-vdw
Copy link

rhys-vdw commented Mar 2, 2017

Oh, totally missed this:

    new StatsPlugin('manifest.json', {
      // We only need assetsByChunkName
      chunkModules: false,
      source: false,
      chunks: false,
      modules: false,
      assets: true
    })]

Perfect.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants