aspnet-webpack icon indicating copy to clipboard operation
aspnet-webpack copied to clipboard

Support multiple bundle files/chunks?

Open joshburgess opened this issue 8 years ago • 4 comments

Hi, I'm using chunks along with the [name] and [hash] filenames to generate multiple bundles (one for all vendor/3rd party modules and a separate one for my own app modules).

Is there any way we can support this? The bundle config param would need to be able to accept an array, and we would need to work out a way to get the right filenames when using placeholders like [name] and [hash].

joshburgess avatar Mar 30 '16 16:03 joshburgess

I was thinking of implementing multiple entry points as this is required for babel-polyfil as noted in #2 Actually as the values for entry point and output file name are passed as arguments to webpack cli I would like to try to pass a value like

['babel-polyfill',  '"app/index.js']

and see the outcome. I will come back with this.

xabikos avatar Apr 04 '16 11:04 xabikos

Sounds good. Any ideas about how using hashes in the file names could be supported? See this project & article for reference:

https://github.com/scottaddie/webpack-aspnet5

http://scottaddie.com/2015/12/14/a-practical-approach-to-cache-busting-with-webpack-and-asp-net-5/

joshburgess avatar Apr 06 '16 16:04 joshburgess

I spent some time to implement the multiple entry points functionality. I created a separate branch for this as I would like your input for that. Please review the commit details here https://github.com/xabikos/aspnet-webpack/commit/649fa9236d71d135895e12358139efbd1a8e5a5f

I added another property in WebpackOptions class that accepts a collection of the new class EntryPoint

Be default the output files will have the shape of [EntryPointName].js. Also all the different entry points are injected by default to the page. If there is a need to only inject the files to certain pages then we need to change the EntryPoint class and add another property like PageRoute to include output to.

Maybe I have missed a case as this is not an easy scenario to cover. If you are happy with that implementation I will merge the code.

Now about the caching issue I would be a bit skeptical to include it. The reason is this package also takes care and inject the scripts to the page so you don't have to include it manually. If we enable cache then I can't see an easy way to do that.

And in any case this is more for the generation of bundles for production. This tool is mainly for usage during development. But if there is a need maybe we can find a workaround.

xabikos avatar Apr 06 '16 18:04 xabikos

@xabikos Thank you for this package! I would also be interested in seeing support for multiple entry points. In my experience this is especially common for Angular 2 applications as even the official docs call out three separate entry points. Right now I am simply importing the polyfills.ts and vendor.ts files directly into my main.ts file but would love to see the multiple entry points in the associated branch added as a feature.

mhheise avatar Aug 19 '16 13:08 mhheise