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.

Minify unbundled files with Terser

See original GitHub issue

Requirements

  1. For each theme that is processed, all deployed .js files that are not in core-bundle.js should be minified through terser
  2. Minified files should be written in-place (same file name) to avoid the need for any path rewriting at build or runtime.
  3. Minification should happen in worker threads, to speed up compilation time and avoid blocking the main thread’s bundling work

Pieces

  • For worker-based minification, there’s already the createMinifier module that will create a pool of minification workers. We’ll want to add a minifyFromFile API, though, so we don’t need to read loose files into memory in the main process and then serialize/transfer/parse in the worker

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
wigmancommented, Dec 9, 2019

This is what a bash script that does this looks like:

THEME_FOLDER=('pub/static/frontend/Magento/luma/')
find ${THEME_FOLDER[@]} \( -name '*.js' -not -name '*.min.js' -not -name 'core-bundle.js' -not -name 'requirejs-bundle-config.js' \) -exec terser \{} -c -m reserved=['$','jQuery','define','require','exports'] -o \{} \;
2reactions
JelleGroenendalcommented, Mar 4, 2020

@GuiltyNL thanks that improved my deploy by 30 minutes 😃

@DrewML missed that thanks love baler so far.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Terser to minify all JavaScript assets in Magento 2
Use Terser to minify all JavaScript assets in Magento 2 · Terser is the JavaScript minifier. · Now, let's bundle files with the...
Read more >
An Introduction to the Rollup.js JavaScript Bundler - SitePoint
The fabulous Terser minifier can compact code by optimizing statements and removing whitespace, comments, and other unnecessary characters. The ...
Read more >
A Future Without Webpack - Pika.dev
To be clear, leaving your application source unbundled isn't all sunshine and roses, either. Large JavaScript files do compress better over the wire...
Read more >
Compressing JavaScript - Patterns.dev
Terser is a popular JavaScript compression tool for ES6+, and Webpack v4 includes a plugin for this library by default to create minified...
Read more >
vite build - patak-dev
If build.minify is 'terser' (currently the default), this plugin is used to minify each rendered chunk using terser . Vite may ...
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