question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose settings to control the minification process(es)

See original GitHub issue

šŸš€ Feature

As a user I’d like to have more control over the minification process.

We have a Docusarus blog that we also use as a source to send email newsletters (about 500k). I’ve noticed that some screenshots are inlined as img src="data:image/png;base64,...". I’m guessing this is based on file size.

As I do not want to have the images in the payload in each email, I’d like to not have them inlined.

Have you read the Contributing Guidelines on issues?

Yes.

Has this been requested on Canny?

No.

Motivation

It’s nice to have some control over the minification process to support different use cases.

API Design

It would be nice to have some optional settings exposed for overriding the default behavior either in Docusaurus config or in the webpack config.

Have you tried building it?

Someone suggested building a remark plugin which seems overly complicated to me, but I’ll check it out.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
stnorcommented, Sep 9, 2021

Yeah absolutely. The PR solves my issue. In the mean time I will hack the value in node_modules.

Again, I would advise to lower the default inlining threshold to 2k or less in order to align with web perf best practices, but this fix lets me override the (imho) broken default via the env, so I’m happy with this.

1reaction
lex111commented, Sep 7, 2021

Images in blog content are handled by inlineMarkdownImageFileLoader, whose options cannot be overridden via configureWebpack for now. If it will be ā€œregular loaderā€, you could do something similar with the existing API:

configureWebpack(_config, isServer) {
  _config.module.rules[0].use[0].options.limit = false;

  return {
    mergeStrategy: {
      'module.rules': 'prepend',
    },
    module: {
      rules: [_config.module.rules[0]],
    },
  };
},

Perhaps this will be possible after migrating to asset modules in PR #4708, although the CRA approach by changing env var still looks better and clearer than using configureWebpack which seems pretty hacky.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Minification | Why minify JS, HTML, CSS files - Imperva
Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used...
Read more >
Configuring W3 Total Cache: Advanced Minification Settings
CSS Minify Settings & @import Handling ... First, enable CSS minification. Next, enable the option for line break removal In contrast toĀ ...
Read more >
API - ESBuild
The build API can take the following options: Simple options: Alias; Bundle; Define; Entry points; External; Format; Inject; Loader; Minify; Outdir; OutfileĀ ...
Read more >
Build Options - Vite
This option allows users to set a different browser target for CSS minification from the one used for JavaScript transpilation. It should only...
Read more >
JavaScript Modules Part 2: Module Bundling - freeCodeCamp
Minification is the process of removing unnecessary characters from source code (e.g. whitespace, comments, new line characters, etc.), in orderĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found