Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable/Disable bundling based on preprocessor #288

Open
ashu66867 opened this issue Oct 18, 2023 · 1 comment
Open

Enable/Disable bundling based on preprocessor #288

ashu66867 opened this issue Oct 18, 2023 · 1 comment

Comments

@ashu66867
Copy link

Is it possible to disable the bundling for DEBUG mode and enable it for RELEASE mode?

I am migrating a .Net framework project, which has the below:
#if DEBUG
BundleTable.EnableOptimizations = false;
#else
BundleTable.EnableOptimizations = true;
#endif
}

Does WebOptimizer have any option or settings to do similar stuff?

@osjoberg
Copy link

Given that you configure AddWebbOptimizer with a pipeline and that you are using the included taghelpers to "render" the bundle just change EnableTagHelperBundling appropriately like this:

#if DEBUG
   var useWebOptimizer = false;
#else
   var useWebOptimizer = true;
#endif

services.AddWebOptimizer(
    pipeline =>
    {
       pipeline.AddJavaScriptBundle("/bundles/js","/scripts/a.js","/scripts/b.js");             
       pipeline.AddCssBundle("/bundles/css","/scripts/a.css","/scripts/b.css");
    },
    option =>
    {
       option.EnableCaching = true;
       option.EnableTagHelperBundling = useWebOptimizer;
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants