问题
i want to load non bundle and non minified css and js file
in my page when i am testing my web site or running my web site from VS IDE with debug mode but after debug when i will deploy the web site in IIS or run the web site from VS IDE with release mode then then always minified version js and css file should load. just guide me what to do or how to achieve this.
i got a trick for the same from web site http://www.davepaquette.com/archive/2014/10/08/how-to-use-gulp-in-visual-studio.aspx
@if (HttpContext.Current.IsDebuggingEnabled)
{
<!-- Bootstrapping -->
<script src="app/app.js"></script>
<script src="app/config.js"></script>
<script src="app/config.exceptionHandler.js"></script>
<script src="app/config.route.js"></script>
<!-- app Services -->
<script src="app/services/datacontext.js"></script>
<script src="app/services/directives.js"></script>
}
else
{
<script src="app/all.min.js"></script>
}
this way we can load non minified
version of js or css file during running or testing web site from VS IDE with debug mode.
but i believe some kind of feature must be there in IDE itself which does the job. i am working with VS IDE 2013.
see the code
code taken from http://www.asp.net/mvc/overview/performance/bundling-and-minification
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
// Code removed for clarity.
BundleTable.EnableOptimizations = true;
}
what this line does BundleTable.EnableOptimizations = true; ?
if some one understand my intention that what i am looking for then please guide me how to achieve this when working with VS IDE 2013/2015
thanks
回答1:
Use preprocessor directives
which tells compiler to preprocess before complation takes place.
in BundleConfig
put this piece of code
#if DEBUG
BundleTable.EnableOptimizations = false;
#else
BundleTable.EnableOptimizations = true;
#endif
来源:https://stackoverflow.com/questions/35889992/how-to-include-non-bundle-and-minified-version-of-js-and-cs-file-during-debuggin