qimingweng / static-render-webpack-plugin

Generates a series of static routes for a website, given an array of routes
http://www.qimingweng.com/writing/webpack-static-render
MIT License
39 stars 2 forks source link

Ability to use chunkname instead of bundle #1

Open nelix opened 9 years ago

nelix commented 9 years ago

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.

qimingweng commented 9 years ago

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

leonfs commented 8 years ago

+1