static-render-webpack-plugin icon indicating copy to clipboard operation
static-render-webpack-plugin copied to clipboard

Ability to use chunkname instead of bundle

Open nelix opened this issue 10 years ago • 2 comments
trafficstars

This would make content hash caching easier. For example ExtractTextPlugin allows this:

new ExtractTextPlugin('[name]-[contenthash].css')

It would be nice if we could do this:

...snip
new StaticSiteGeneratorPlugin('app-[contenthash].js', routes)

...snip
var entry = {
  app: './app',
  hot = [
    'webpack-dev-server/client?http://localhost:8080',
    'webpack/hot/only-dev-server',
    './app',
  ]
}
...snip
  output: {
    filename: '[name]-[contenthash].js',
    path: path.join(__dirname, 'dist'),
    // This is really important, the plugin expects the bundle output to export a function!
    libraryTarget: 'umd',
  },

And then some way to get paths to these assets into the props of the app... I tried to hack something together like this:

    var assets = compiler.getStats().toJson().assetsByChunkName[self.bundlePath];
    var sourceAsset = compiler.assets[assets && assets[0]];

But I don't really know what I am doing :P And haven't managed to get the paths into the app to load them yet.

nelix avatar Aug 01 '15 04:08 nelix

Webpack's compiler is hideously undocumented, so please let me know if you make developments on that front. Good point about this though.

qimingweng avatar Aug 01 '15 07:08 qimingweng

+1

leonfs avatar Jul 19 '16 17:07 leonfs