-
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
Autobundler does not work in case ScriptResourceLinks() in master page and AddScriptResources in a view page section #331
Comments
I haven't looked at this in a long time, and have been considering pulling it from v1.0 (I don't use it, and this is the first its been mentioned other than initial discussions with @syndicatedshannon). I think it might make more sense as an add on package anyway. If you can upload a project somewhere that will replicate the issue for me I will take a look, but I will not have time to start from scratch. |
Here is the PR with tests: #332 |
Autobundler is actually a killer feature and a time-saver. |
Good to know - if thats the case I will keep it, as long as it doesn't get too difficult to maintain. Maybe when v1.0 gets out I will have time to write some documentation. I'll take a look at the test in the next few days. |
I think the problem you're seeing is because anything in the section is not executed until RenderSection is called. If you call that before writing the resource links into the page, eg
then it should work. Let me know what you find out. |
Well, this is not an actual workaround since i need |
In that case I think you're going to need to raise the issue with the MVC team :) |
Out of curiosity, why do you need them in that order? It seems counter-intuitive to the way autobundling works - you need to make sure that all of your view content has been rendered to ensure that the complete set of content for the bundle is available. |
I add some scripts that must be in the page header for instance, at the same time I have many legacy pages that have those scripts included in the section parts. |
Moreover, I do need priority for script inclusion in autobundler |
I would review a pull request for Priority, but mostly think that if order matters you should not be using autobundler. I would not even consider delaying script tag rendering. It sounds like ClientDependency is able to meet your needs pretty well (possibly because of the tight coupling that you find problematic?). Suggest working with them to figure out any minifier issues you are having. |
What I want to do is: make the scripts rendered in master page, but the file itself added inside arbitrary views.
So i have a layout page with a section defined. I add scripts in a view within the section and they are not rendered.
If I add scripts outside of the section then they are rendered OK
The text was updated successfully, but these errors were encountered: