Basic bundling of CDN in debug mode - asp.net-mvc-5

Using the following:
bundles.Add(new ScriptBundle("~/bundles/myBundle", "//cdn.com/myscript.js").Include("~/Scripts/myscript.js"));
I can load from a CDN path in production, and fall back to a local copy of myscript.js in debug mode.
Great, but I don't want to do this - I want to load from the CDN path all the time, even in debug mode.
I tried supplying a CDN path in the Include method but I get an error since it needs to be a relative path (makes sense).
How can I load from the CDN permanently via bundling (regardless of 'mode')?

You can add this code in Application_Start()
BundleTable.EnableOptimizations = true;

Related

Static path Express + Nginx

I have very strange behavior in my application. I want to add multiply static path to my app.js file.
First for main application:
app.use(express.static(path.join(__dirname, 'public')));
And second for landing pages which located in 'ads' directory.
app.use('/ads', express.static(path.join(__dirname, 'ads')));
Folder structure:
public
- build
- ...
ads
- currency
- public
- build
- 1.css
- 2.js
- index.html
...
app.js
In my main application all JS and CSS files loading successfully, but when i get in to path /ads/currency my index.html loaded but .css, .js and images don't. However if i pass to command line /ads/currency/public/build/1.css it is loading normal.
Does someone know about it?
Screenshots was attached:
Nginx config:
It has nothing to do with your configuration but might be related to Chrome (i.e. an extension), since the error says ERR_BLOCKED_BY_CLIENT.
Check your ad blockers log. The keyword ads in the path might be blocked, since a filter might try to catch a javascript miner.
You should make sure the move the whole "ads" part into a different folder - avoiding the keyword "ads" at all. Disabling the ad blocker might work for you know, bot not for your users

ServiceStack: Self-Host LiveReload not working

I have a self hosted ServiceStack application which I intend to use to develop an angular application with.
The problem is, previously, every time I've made a change to a static file, I've had to restart all the services for it to pick up the changes.
I'm wondering if I'm missing something? I've enabled the LiveReload option from RazorFormat but it doesnt seem to have done anything? I still have to restart the whole application for it to pick up changes?
I've created a small repro here: https://github.com/CallumVass/ServiceStackSelfHost
If I make changes to the Default.cshtml file the changes arent picked up until I restart the service?
The issue is that he was changing the source file and not the output file. Since SS copies the files to /bin/debug he needed to change that version.
Using HostConfig settings, we were able to to use the WebHostPhysicalPath property in the following way during development, while setting up the SS Config:
SetConfig(new HostConfig {
#if DEBUG
DebugMode = true,
WebHostPhysicalPath = Path.GetFullPath(Path.Combine("~".MapServerPath(), "..", "..")),
#endif
});
This took us out of /bin/debug and back to the source.
You need to set the AppHost config to debug mode:
SetConfig(new HostConfig {
DebugMode = true,
});
For performance reasons changes are only monitored for in Debug mode. See here for more information.
Automatic reload of modified views, layout templates and partials (in Debug mode)
The best way to avoid the Start-Up penalty is to avoid having to restart the AppDomain in the first place. So in Debug Mode we'll also do this where a background file system watcher monitors all pages, partials and Layout templates for modifications and recompiles and auto-reloads them on the fly, all-ready to deliever instant response time once the page is requested.

requireJS not updating, still references a deleted file

I used to reference a file called OptionRendererController.js, but I deleted the reference and the file. When I grep my app's directory for OptionRenderer, no results appear, and I've made sure to include urlArgs: "buset=" + (new Date()).getTime() to prevent browser caching, and I restart the python server on which I'm running my app, but I still get a 404 error on the deleted OptionRendererController.js file. How can I make sure my app no longer references that file?
It worked after I restarted Chrome.

grails 2.1.1 does not reload static resources

I have a fresh grails 2.1.1 installation, windows 7.
Problem: Static resources (CSS) don't reload in development mode.
According to http://grails.1312388.n4.nabble.com/Re-Grails-2-0-CSS-Changes-not-Picked-Up-td3680479.html I've tried in Config.groovy:
environments {
development {
grails.resources.processing.enabled = false;
}
}
Result: no CSS is loaded at all. Chrome needs 30 seconds to load a page, and does not load any CSS.
I reverted that change.
Then, according to http://grails.1312388.n4.nabble.com/disabling-static-resource-stuff-td3827384.html
I've tried to uncomment the plugins runtime ":resources:1.1.6"
Now I'm back to how it was initially, CSS files are served but not reloaded.
What works temporarily is the hack mentioned here:
http://grails.1312388.n4.nabble.com/The-resources-plugin-is-not-reloading-my-CSS-and-JS-of-a-bundle-td3857137.html
Top append to the url: ?_debugResources=y
How do I make static resources being reloaded in development mode? Shouldn't that be the default anyway? It doesn't make any sense in my opinion to reload gsp's (which it does) but not the static resources.
I set the grails.resources.debug flag in Config.groovy on debug to get the URL to be appended like this
css/main.css?_debugResources=y&n=1386063248351
environments {
development {
grails.resources.debug = true
}
production {
}
}
Any URL in your application can have the query parameter _debugResources=y added to it, and the request will perform no processing. So for example if you are browsing http://localhost:8080/myapp/admin and need to bypass resources, just change the URL in your browser to http://localhost:8080/myapp/admin?_debugResources=y
Reference Link : https://grails-plugins.github.io/grails-resources/guide/8.%20Debugging.html

Bundling not happening when deployed to production server

I have created a bundle. However its not working when deployed to production server. I am running MVC4 RC
My bundle looks like
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/core").Include("~/Scripts/min/jquery-1.*",
"~/Scripts/min/core.js",
"~/Scripts/min/business-signup.js",
"~/Scripts/min/slider.js",
"~/Scripts/min/label-text.js",
"~/Scripts/min/consumer-account.js",
"~/Scripts/min/modernizr-2*"));
bundles.Add(new StyleBundle("~/Content/min/css").Include(
"~/Content/min/core.css",
"~/Content/min/layout.css",
"~/Content/min/reset.css",
"~/Content/min/sprite.css",
"~/Content/min/pricing.css",
"~/Content/min/homepage-slider.css",
"~/Content/min/transactions.css"));
}
From my layout I call the bundles like
#Styles.Render("~/Content/min/css","~/Content/min/css")
#Scripts.Render("~/bundles/core")
However there is no minifaction or bundling happening. Instead a single request is made for each of the items within the the bundles.
I know the server is working correctly as I have another site running on the same server and the bundling is working ok.
Can anyone see something obvious to what I am doing wrong?
Make sure you are running in Release mode (debug="false" in your web.config). Also notice that there is a bug in the RC that prevents of properly caching the resources server side and thus increasing the CPU usage of your site everytime a request is made to the url that is supposed to serve the bundled and minified version of your resources.

Resources