Movatterモバイル変換


[0]ホーム

URL:


@rushstack/webpack5-module-minifier-plugin
TypeScript icon, indicating that this package has built-in type declarations

5.5.107 • Public • Published

This package contains a plugin for webpack 5 that performs minification on a per-module basis rather than per-asset to deduplicate and parallelize compression work.

Installation

npm install @rushstack/webpack5-module-minifier-plugin --save-dev

Overview

This Webpack plugin performs minification of production assets on a per-module basis, rather than minifying an entire chunk at a time.It issues async calls to the minifier for each unique module and each unique set of chunk boilerplate (i.e. the webpack runtime and the structure of the module list).This improves minification time by:

  • Avoiding duplicate work for each module that is included in multiple distinct assets/chunks (this is common with async chunks)
  • Handing smaller code chunks to the minifier at a time (AST analysis is superlinear in size of the AST)
  • Even single asset builds will likely still contain multiple modules in the final output, which can be split across available CPU cores

Use with[hash] and[contenthash] tokens

The plugin will do its best to update webpack hashes if changing the direct inputs (useSourceMap) to the plugin, but if altering theminifier property itself, you may need to use theoutput.hashSalt property to force a change to the hashes, especially if leveraging theMessagePortMinifier or similar, since it has no direct access to the configuration of the minifier.

Parallel execution

const{ ModuleMinifierPlugin}=require('@rushstack/webpack5-module-minifier-plugin');const{ WorkerPoolMinifier}=require('@rushstack/module-minifier');// In your webpack options:optimization:{minimizer:[newModuleMinifierPlugin({minifier:newWorkerPoolMinifier(),// If not provided, the plugin will attempt to guess from `mode` and `devtool`.// Providing it expressly gives better resultsuseSourceMap:true})]}

Single-threaded execution

You can also run the ModuleMinifierPlugin in a single-threaded configuration.

// webpack.config.jsconst{ ModuleMinifierPlugin}=require('@rushstack/webpack5-module-minifier-plugin');const{ LocalMinifier}=require('@rushstack/module-minifier');// In your webpack options:optimization:{minimizer:[newModuleMinifierPlugin({minifier:newLocalMinifier()})]}

Links

@rushstack/webpack5-module-minifier-plugin is part of theRush Stack family of projects.

Readme

Keywords

none

Package Sidebar

Install

npm i @rushstack/webpack5-module-minifier-plugin

Weekly Downloads

6,087

Version

5.5.107

License

MIT

Unpacked Size

263 kB

Total Files

31

Last publish

Collaborators

  • rushstack-admin
  • odspnpm
  • octogonz

[8]ページ先頭

©2009-2025 Movatter.jp