I am trying to use the bundles feature in ASP.NET MVC in my project, everything works great in my local, if I switch the compilation debug property to false I can see that the bundle is being generating with a version (v=XXXXXXX) and my application keeps working.
When I deploy the application to a server and request the page, the bundle is there but the v= value is empty. Is there anything I am missing?
<script src="/bundles/bundlename?v="></script>
One of the possible cases you have is with optimization side of bundles. I had the same issue with my scripts and styles when I started to use minified versions. For example, if I specified in bundle configuration with .min.js file then you can fall into problem when optimization framework minifies already minified script(s). And it also occurs only in release mode. I solved it with BundleTable.EnableOptimizations = false; in BundleConfig.cs file after all bundles' configs
I think you miss specific root path since locally its not the same vs server side.
Why don't you use the script helper from the framework:
#Scripts.Render("~/bundles/bundlename")
I found the issue, after trying everything I went back an check the build scripts on the TFS server, we have continuous integration configured, turns out the build server was removing the .js and only letting the .min.js files on the final build. I removed that instruction and it started working.
Basically the .js did not exist on the server so there was nothing to bundle.
Thank you guys for your help!
Related
so I am making an application that requires a backend API, and it uses certain node_modules which don't work when compiling with Electron. To fix this, I put the API code into a separate JavaScript file, which I am attempting to fork using child_process.
I have gotten this to work when compiling, but it immediately stops working after I move the "win-unpacked" folder or try to install the app using the compiled installer.
I have checked, and it is not the path that is wrong, it is correctly pointing to the file. From testing, it appears that the file actually does get forked, but immediately exits with the status code 1.
I can't use require(./filepath.js) because that will just include the code in the compiler, which doesn't work with the modules I am using.
I am hoping someone knows what is wrong and what I should do to fix it, or have any ideas for other ways to run the server code without including it in the compiler.
I am using Vue.js 3 and vue-cli-electron-builder version 2.1.1
The server I am attempting to run is a express server.
When I turn on bundling everything bundles and minifies correctly except my angular.js file.
I get the following error:
"Minification failed. Returning unminified contents. (173,115-122):
run-time error JS1019: Can't have 'break' outside of loop: break a"
However it seems to return a minified result and the site doesn't load.
I have tried updating the file to angular 1.5.8, and tried bundling the .min.js file but no success.
What I end up doing is just remove angular.min.js from project and let ASP bundling process to minimize angular.js and produce final minimized package.
Sometimes I had to do same trick with other JS libs (if my memory serves JQquery..)
Also in our solution we use .min.js files, but devs forget to regenerated this file from source and there were cases when release version had "fixed" but not fixed version of the file. I gave up fighting with this and just deleted all .min.js files. -))
I have the following bundle configuration for my javascript.
`BundleTable.Bundles.Add(new ScriptBundle("~/Includes/Shop/js/bundles/abc").Include(
"~/Includes/Shop/js/vendor/jquery-{version}.js",
"~/Includes/Shop/js/vendor/jquery-ajaxq.js",
"~/Includes/Shop/js/vendor/knockout-{version}.js",
"~/Includes/Shop/js/vendor/lodash-{version}.js"
));`
The issue is when I call it in my partial view, it's just outputting the "Includes/Shop/js/bundles/abc" as the script source. The optimization part is turned off.
Should point out I am using this with sitecore cms.
[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(NAMESPACE.UI.BundleConfig), "Start")]
What would cause the bundle not to output these files, I know they exist on the file system.
The issue turns out to have been the version of web grease, 1.5.2 didn't work, but 1.6 did.
i had that issue once i've just re run the nuget-package installation commands of webgrace and optimization then it worked out
I use Visual Studio 2013 and .NET 4.5 for an MVC project.
I've learning to use AngularJS via several videos on Pluralsight and one of them walks through the process of using Grunt to clean the output directory, then use ngmin to min-safe the Javascript files.
My process is using a gruntfile.js to clean and run ngmin against the javascript files in my solution, then put them in a directory called app_built. This is executed via a batch file in the pre-build for the project and then I include it via a ScriptBundle with IncludeDirectory pointing to the app_built directory. My intent is to use the Bundling features of .NET 4.5 to do the rest of the minification and concatenation of the Javascript after all the files have been min-safed via Grunt.
I specify the path to the min-safed files with the following:
bundles.Add(new ScriptBundle("~/bundles/minSafed")
.IncludeDirectory("~/app_built/", "*.js", true));
If I run this on my local machine, it runs fine without a hitch. The Javascript is minified and bundled as I'd expect and the resulting web application runs fine as well.
If I publish the website to a remote server, I get a server error that the "Directory does not exist. Parameter name: directoryVirtualPath". I assume this error is saying that it's unable to find the directory populated with my many *.js files. I also assume this is because they weren't published since they aren't part of the solution, even though the folder they reside in is a part of the solution (it's just empty within the solution explorer in Visual Studio).
If my assumption is correct, what can I do to add these files to my solution so they'll be published with the rest of my web application with minimal effort on my end each time?
And if I'm incorrect in the assumption, what I can I do to resolve this otherwise?
Thanks!
I never did find a great way of going about this. I found information at http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx that seems related, but I was unable to make it work.
Rather, since I knew the name of the outputted file, I simply created such an empty file in my project and referenced that where I needed to. I then had the pre-build task replace the contents of that file with the externally minified version and it would be packaged with the project as necessary, so it works well enough.
I am pleased with how quickly I can get my AngularJS and Firebase app deployed to Firebase Hosting, but it appears that local CSS and JavaScript files are bundled and minified as part of executing $firebase deploy
I would like to debug the JavaScript after deploying. How do I turn off bundling and minification as part of the deploy?
We're currently in beta and this is something we will be implementing soon but I'm afraid at this time it's not possible to turn off the minification and bundling on deploy.
We've just removed the minification step from the processing we do on the uploaded files so if you redeploy this should be working for you. Because of the way we handle caching, you might need to make a change to the html files that link to the scripts (even just a trivial whitespace change) before they reflect the changes.