I would like to minify and obfuscate javascript files of my Web Application (not MVC). I based my code on this simple configuration: http://ift.tt/2nEbEnS, but it seems to have no effect on js files when viewed from the browser. I did not understand if Bundle Transformer is only applicable to MVC Web Applications. I installed BundleTransformer.Core, BundleTransformer.Yui, Microsoft.AspNet.Web.Optimization.
Global.asax.cs:
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
var nullOrderer = new NullOrderer();
var scriptBundle = new CustomScriptBundle("~/jscbundle/");
scriptBundle.Include("~/js/main.js");
scriptBundle.IncludeDirectory("~/js/", "*.js", true);
scriptBundle.Orderer = nullOrderer;
bundles.Add(scriptBundle);
BundleTable.EnableOptimizations = true;
}
}
protected void Application_Start(object sender, EventArgs e)
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
Web.Config:
<system.web>
<compilation debug="false" targetFramework="4.5" />
...
</system.web>
<bundleTransformer xmlns="http://ift.tt/1t6exWG">
<core>
<css>
<minifiers>
<add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
<add name="YuiCssMinifier" type="BundleTransformer.Yui.Minifiers.YuiCssMinifier, BundleTransformer.Yui" />
</minifiers>
<translators>
<add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
</translators>
</css>
<js defaultMinifier="YuiJsMinifier">
<minifiers>
<add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
<add name="YuiJsMinifier" type="BundleTransformer.Yui.Minifiers.YuiJsMinifier, BundleTransformer.Yui" />
</minifiers>
<translators>
<add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
</translators>
</js>
</core>
</bundleTransformer>
Aucun commentaire:
Enregistrer un commentaire