How to generate sourceMap using WebOptimizer in asp.net?

In my startup.cs file I have the following code

services.AddWebOptimizer(pipeline =>
{
    // bundle .js files
    pipeline.AddJavaScriptBundle("/bundle.js", // bundle file to be created in memory 
                                "/assets/js/jquery-1.12.4.min.js",
                                //"/assets/js/bootstrap-4.3.1.min.js",
                                "/assets/js/crypto-js.4.0.0.min.js",
                                "/assets/js/gijgo.min.js", // removing it causes draggable errors
                                "/assets/js/plugins.js",
                                //"/assets/js/jquery.slicknav.js", // this line was breaking the footer
                                //"/assets/js/slick.js",
                                //"/assets/js/main.js",
                                "/js/siriwave.umd.js",
                                "/js/dat.gui.js",
                                "/js/speech-bundle.js",
                                "/js/pageLoad.js",
                                "/assets/js/html2canvas.min.js");

    // bundle .css files
    pipeline.AddCssBundle("/bundle.css",
                            //"/assets/css/bootstrap-4.3.1.min.css", // for some reason this css file breaks if bundled
                            "/assets/css/slicknav.min.css",
                            "/assets/css/flaticon.min.css",
                            "/assets/css/animate.min.css",

Now I want to enable soucreMap so that I can debug the code in production or Staging environment. How Can I achieve this? There is nothing such thing in the documentation.

Upvotes: 0

Views: 121

Answers (1)

Jason Pan
Jason Pan

Reputation: 22082

After checking the source code, we can enable soucreMap like below.

The value of GenerateSourceMap is false by default.

services.AddWebOptimizer(pipeline =>
{
    // bundle .js files
    pipeline.AddJavaScriptBundle("/bundle.js", // bundle file to be created in memory 
                                // enable soucreMap
                                new WebOptimizer.Processors.JsSettings { GenerateSourceMap = true },
                                "/assets/js/jquery-1.12.4.min.js",
                                //"/assets/js/bootstrap-4.3.1.min.js",
                                "/assets/js/crypto-js.4.0.0.min.js",
                                "/assets/js/gijgo.min.js", // removing it causes draggable errors
                                "/assets/js/plugins.js",
                                //"/assets/js/jquery.slicknav.js", // this line was breaking the footer
                                //"/assets/js/slick.js",
                                //"/assets/js/main.js",
                                "/js/siriwave.umd.js",
                                "/js/dat.gui.js",
                                "/js/speech-bundle.js",
                                "/js/pageLoad.js",
                                "/assets/js/html2canvas.min.js");

    // bundle .css files
    pipeline.AddCssBundle("/bundle.css",
                            //"/assets/css/bootstrap-4.3.1.min.css", // for some reason this css file breaks if bundled
                            "/assets/css/slicknav.min.css",
                            "/assets/css/flaticon.min.css",
                            "/assets/css/animate.min.css",
                            ...

Upvotes: 1

Related Questions