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

Bundle files without minifying them #71

Open
LisaTatum opened this issue Dec 9, 2017 · 6 comments
Open

Bundle files without minifying them #71

LisaTatum opened this issue Dec 9, 2017 · 6 comments

Comments

@LisaTatum
Copy link

Hi,

from your main site:
"Bundling is the process of taking multiple source files and combining them into a single output file. All CSS and JavaScript bundles are also being automatically minified."

I want to debug my code during development thus I do not want minified code, but I want it bundled as my index.cshtml file always references a single all.js file.

How can I disable the minification of a bundle?

@hellfirehd
Copy link
Contributor

Instead of using AddJavaScriptBundle(...) use a custom pipeline:

pipeline.AddBundle("/js/bundle.js", "text/javascript; charset=UTF-8", "/js/a.js", "/js/b.js")
  .Concatenate(); // This is what makes the bundle

@enkelmedia
Copy link

enkelmedia commented Apr 13, 2021

I would say that passing a "CodeSettings" instance to the AddJavaScript bundle like

pipeline.AddJavaScriptBundle("/bundle-frontend.js",
                        new CodeSettings()
                        {
                            MinifyCode = false
                        },
                        "/js/helper.analytics.js",
                        "/js/view.frontend.site.js",
                    );

Should be respected, right now it's not

I just made a copy of it to solve this temporary:

public static IAsset AddJsBundle(
            this IAssetPipeline pipeline,
            string route,
            CodeSettings settings,
            params string[] sourceFiles)
        {
            if(settings.MinifyCode)
                return pipeline.AddBundle(route, "text/javascript; charset=UTF-8", sourceFiles)
                    .EnforceFileExtensions(".js", ".jsx", ".es5", ".es6")
                    .Concatenate()
                    .AddResponseHeader("X-Content-Type-Options", "nosniff")
                    .MinifyJavaScript(settings);

            return pipeline.AddBundle(route, "text/javascript; charset=UTF-8", sourceFiles)
                .EnforceFileExtensions(".js", ".jsx", ".es5", ".es6")
                .Concatenate()
                .AddResponseHeader("X-Content-Type-Options", "nosniff");
        }

@felovala
Copy link

felovala commented May 2, 2022

Any chance this will be implemented/fixed? The AddJavaScriptBundle does not allow to prevent the file from being minified even if you pass the settings.

@TechLiam
Copy link
Contributor

Submitted #245 to try and address this

@cadilhac
Copy link

Can't wait to get this fix in the next nuget.

@TechLiam
Copy link
Contributor

TechLiam commented Oct 6, 2022

The fix I did has now been released which I thought I'd put here as I checked on it today

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

6 participants