-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add to bundle in partial views then render in master/layout view #336
Comments
I'd be willing to take a shot at implementing it if not supporting - if @AlexCuse could point me in the right direction. |
There is support that @syndicatedshannon added a while back. See the AspNetMvcTest for details, under "Auto-Bundling" The code to support it is in SquishIt.Mvc. |
I'll take a look |
Hey guys. Didn't mean to start something and bail. I transitioned to Angular almost right after I got involved here, but would still be glad to lend a hand if I can. @brgrz , want to chat? |
Hey, I don't really know what autobundling feature was all about, I have to look at it but didn't have time yet. Will probably do it on friday. In the meantime, if you could explain what it was about? |
Also I see #337 and this one related meaning we could have server side modules which register scripts and styles they need and we'd render them out as needed per current view/module that's active since with HTTP/2 we don't have to bundle anymore (some say it still makes sense to but let's assume for these two issues that we don't bundle anything anymore). So we truly get views that load up only the resources they really need. |
If you look at that view I linked, the two HtmlHelper extension methods are what you are after. .AddResources adds the various resources, then .ResourceLinks renders them. You can also use .AddScriptResources / .AddStyleResources and .StyleResourceLinks / .StyleResourceLinks if you want to add/render in different sections of the page. .AddResources routes to the appropriate bundle by file extension. https://github.com/jetheredge/SquishIt/blob/master/SquishIt.Mvc/HtmlHelperExtensions.cs @syndicatedshannon this seems to work well just wanted to give you credit for the work. The fact it is not documented is on me 😃 |
@syndicatedshannon @AlexCuse this seems to do what I am after but it doesn't render minified and hash-stamped files. Another thing, I am using custom view engine to locate views. My views register resources they require which are commonly placed in the folder right next to them. When I used my own code to render out links, I registered them by also providing ViewVirtualPath to the registration method which then rewrited the href/src accordingly. SquishIt of course currently cannot do that and points them to the root of the site. This is what it renders (note that the view virtual path actually is there available to SquishIt it just doesn't use it):
|
Looking at the Autobundler class I think what I need is a convention in place that would say when viewPath.startsWith(" As per the above example I'd take the
My question is, should I implement that in the Autobundler class? |
What do you mean "but it doesn't render minified and hash-stamped files." - are you running in debug mode? I would expect release bundle rendering to go through the same pipeline, rendering a single minified, hashed file per bundle. It sounds like you have a very specialized use case, and probably would want to implement your own auto-bundler. If we can help by adding extensibility points to the existing auto-bundler I am all ears. |
I can't seem to find an example whether it is possible to add to a bundle in different views across the application then render the bundle in master/layout view.
I tried but the bundle seemed to be empty when rendering.
A step further would be to have named bundles, adding scripts to them,then render them out by name.
The text was updated successfully, but these errors were encountered: