1

Sitecore/SXA 10.2

I find it very difficult to know exactly which part of my code is broken when the theme scripts are mangled beyond my comprehension. What can I do to improve this experience?

Take for example this piece of code:

Minified

Minified

Original

Original

Note: I'm using a CDN which handles the minify process in production.

1 Answer 1

1

There may be other options available, but the easiest I found begins in the config.js included with the SXA theme. Making the configuration changes below will result in a pre-optimized-min file bundled with the variable/function names intact.

Here is the original minifyOptions provided:

minifyOptions: {
    js: {
        compress: {
            hoist_funs: true,
            passes: 1
        },
        toplevel: false
    },
    css: { compatibility: 'ie8' }
}

Here is the updated minifyOptions:

minifyOptions: {
    js: {
        compress: false,
        mangle: false,
        toplevel: false
    },
    css: { }
}

Note: SXA makes use of the npm-uglify-es and npm-clean-css packages.

1
  • This worked for me on 10.2, thanks! Commented Feb 28, 2023 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.