soundcloud / chunk-manifest-webpack-plugin

Allows exporting a manifest that maps entry chunk names to their output files, instead of keeping the mapping inside the webpack bootstrap.
MIT License
395 stars 73 forks source link

Update to use chunkhash filename #11

Closed gingur closed 8 years ago

gingur commented 8 years ago

If a webpack config specifies a output.chunkFilename it should be used over output.filename.

gingur commented 8 years ago

Example config:

...
output: {
    path: path.join(libPath, 'client', 'assets'),
    filename: '[name].[chunkhash].bundle.js',
    chunkFilename: '[name].[chunkhash].chunk.js',
    publicPath: '/assets/'
},
plugins: [
    new WebpackMd5Hash(),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: Infinity
    }),
    new ManifestPlugin(),
    new ChunkManifestPlugin({
      filename: 'chunk-manifest.json',
      manifestVariable: 'webpackManifest'
    }),
    new webpack.optimize.OccurrenceOrderPlugin()
    ....
]

Example manifest.json before:

{
  "client.js": "client.f9f576a0309aeace48bc.bundle.js",
  "client.js.map": "client.f9f576a0309aeace48bc.bundle.js.map",
  "test-client.js": "test-client.7afae07c548189b45803.chunk.js",
  "test-client.js.map": "test-client.7afae07c548189b45803.chunk.js.map",
  "test-route.js": "test-route.328a03f54933c8bd6618.chunk.js",
  "test-route.js.map": "test-route.328a03f54933c8bd6618.chunk.js.map",
  "vendor.js": "vendor.39d04e1db2638beab3c1.bundle.js",
  "vendor.js.map": "vendor.39d04e1db2638beab3c1.bundle.js.map"
}

Example chunk-manifest.json before:

{
  "1": "test-route.328a03f54933c8bd6618.bundle.js",
  "2": "client.f9f576a0309aeace48bc.bundle.js",
  "3": "test-client.7afae07c548189b45803.bundle.js"
}

Example manifest.json after:

{
  "client.js": "client.f9f576a0309aeace48bc.bundle.js",
  "client.js.map": "client.f9f576a0309aeace48bc.bundle.js.map",
  "test-client.js": "test-client.7afae07c548189b45803.chunk.js",
  "test-client.js.map": "test-client.7afae07c548189b45803.chunk.js.map",
  "test-route.js": "test-route.328a03f54933c8bd6618.chunk.js",
  "test-route.js.map": "test-route.328a03f54933c8bd6618.chunk.js.map",
  "vendor.js": "vendor.39d04e1db2638beab3c1.bundle.js",
  "vendor.js.map": "vendor.39d04e1db2638beab3c1.bundle.js.map"
}

Example chunk-manifest.json after:

{
  "1": "test-route.328a03f54933c8bd6618.chunk.js",
  "2": "client.f9f576a0309aeace48bc.chunk.js",
  "3": "test-client.7afae07c548189b45803.chunk.js"
}
diurnalist commented 8 years ago

Good catch 👍