Reputation: 763
In one of my razor page I have the following in the scripts section
@Scripts.Render("~/bundles/script1")
@Scripts.Render("~/bundles/script2")
@Scripts.Render("~/bundles/script3")
The problem is it will render 3 JavaScript files. Is there any way they can be bundled in one file without changing the BundleConfig file?
Thanks,
Upvotes: 0
Views: 1526
Reputation: 54666
The problem is it will render 3 JavaScript files. Is there any way they can be bundled in one file without changing the BundleConfig file?
No, you will have to change your BundleConfig.
Well, if you want to reuse script1 in another page, how will you do that?
Make a script bundle include another script bundle
Upvotes: 2
Reputation: 322
why would You do this ? copy the code from these 3 files and paste it to one.js file then pass it to bundles.
Upvotes: 0
Reputation: 333
Yes you can create a Bundle containing all the files from Script1, 2 and 3 Bundles and then lets say if its called ScriptAll bundle then you can render it with 1 line. Unfortunately you will have to change your BundleConfig
@Scripts.Render("~/bundles/scriptall")
Upvotes: 0