vmariano
vmariano

Reputation: 493

how to config web.config for debug/release bundle minification?

i´m trying to configure bundle minifications on/off depending on if is a release or debug configuration.

After a while, when the build is pointed to release i still got unminified field.

I just added

        #if DEBUG
            BundleTable.EnableOptimizations = false;
        #else
            BundleTable.EnableOptimizations = true;
        #endif

But I would like if is possible has this configuration in the Web.Debug.config/Web.Release.config respectively instead of use a compiler directive.

Upvotes: 1

Views: 172

Answers (1)

haim770
haim770

Reputation: 49113

Whether to optimize or not is not directly dependent on the build configuration but rather on the following flag:

HttpContext.Current.IsDebuggingEnabled

And the above is read from your Web.Config:

<compilation debug="true" />

So, if your solution is configured to remove this debug flag as part of your RELEASE build transformation then you'll have optimization turned on without the need to explicitly call BundleTable.EnableOptimizations.

So, make sure your RELEASE build transformation is indeed removing the debug flag.

More on Bundling & Minification

Upvotes: 1

Related Questions