@rsbuild/plugin-css-minimizer
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@rsbuild/plugin-css-minimizer

An Rsbuild to customize the CSS minimizer, switch to cssnano or other tools for CSS compression.

@rsbuild/plugin-css-minimizer internally integrates css-minimizer-webpack-plugin.

npm version license

Usage

Install:

npm add @rsbuild/plugin-css-minimizer -D

Add plugin to your rsbuild.config.ts:

// rsbuild.config.ts
import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";

export default {
  plugins: [pluginCssMinimizer()],
};

Options

pluginOptions

Used to customize the options of css-minimizer-webpack-plugin.

The value of pluginOptions will be merged with the default options inside the plugin using Object.assign and then passed to the css-minimizer-webpack-plugin. You can refer to the README documentation of css-minimizer-webpack-plugin to explore all available options.

  • Type: Object | Function | undefined
  • Default:
const defaultOptions = {
  minify: CssMinimizerWebpackPlugin.cssnanoMinify,
  minimizerOptions: {
    preset: [
      "default",
      {
        mergeLonghand: false,
      },
    ],
  },
};
  • Example 1: modify the preset configuration of cssnano.
pluginCssMinimizer({
  pluginOptions: {
    minimizerOptions: {
      preset: require.resolve("cssnano-preset-simple"),
    },
  },
});
  • Example 2: pass a function to modify the default options.
pluginCssMinimizer({
  pluginOptions: (options) => {
    options.minimizerOptions = {
      preset: require.resolve("cssnano-preset-simple"),
    };
  },
});
  • Example 3: Switch to other tools for CSS minification.
import {
  pluginCssMinimizer,
  CssMinimizerWebpackPlugin,
} from '@rsbuild/plugin-css-minimizer';

pluginCssMinimizer({
  pluginOptions: {
    minify: CssMinimizerWebpackPlugin.cleanCssMinify,
    minimizerOptions: {
      level: {
        1: {
          roundingPrecision: "all=3,px=5",
        },
      },
    },
  },
}),

License

MIT.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.7.0-beta.9
0beta
0.0.0-nightly-20240114070311
0nightly
1.0.224,829latest
1.0.0-alpha.3
1alpha
0.0.0-next-20240528072128
1next

Version History

VersionDownloads (Last 7 Days)Published
1.0.224,829
1.0.192
1.0.0-alpha.3
1
1.0.0-alpha.2
0
1.0.0-alpha.1
0
1.0.0-alpha.0
1
0.7.10
41
0.7.9
5
0.7.8
1
0.7.7
1
0.7.6
1
0.7.5
1
0.7.4
1
0.7.3
21
0.7.2
0
0.7.1
0
0.0.0-next-20240528072128
1
0.7.0
0
0.7.0-beta.9
0
0.7.0-beta.8
1
0.7.0-beta.7
1
0.7.0-beta.6
2
0.7.0-beta.5
1
0.7.0-beta.4
0
0.7.0-beta.3
0
0.7.0-beta.2
0
0.7.0-beta.1
0
0.7.0-beta.0
1
0.0.0-next-20240514150515
1
0.6.15
8
0.0.0-next-20240513013836
0
0.6.14
1
0.0.0-next-20240510033042
0
0.6.13
1
0.6.12
0
0.0.0-next-20240507105013
0
0.6.11
12
0.6.10
0
0.6.9
0
0.6.8
0
0.6.7
0
0.6.6
2
0.6.5
1
0.6.4
0
0.6.3
53
0.6.2
1
0.6.1
1
0.0.0-next-20240411025907
0
0.6.0
1
0.0.0-next-20240409053424
0
0.5.9
1
0.5.8
1
0.5.7
0
0.5.6
0
0.5.5
1
0.0.0-next-20240329044111
0
0.0.0-next-20240328110637
1
0.0.0-next-20240328105907
1
0.5.4
0
0.5.3
2
0.5.2
0
0.5.1
13
0.5.0
0
0.0.0-next-20240318111129
0
0.0.0-next-20240313074838
0
0.4.15
0
0.4.14
0
0.4.13
0
0.4.12
1
0.4.11
1
0.4.10
1
0.4.9
0
0.4.8
175
0.4.7
1
0.0.0-next-20240227024230
1
0.0.0-next-20240227022717
1
0.4.6
0
0.4.5
0
0.4.4
1
0.4.3
1
0.4.2
0
0.4.1
0
0.4.0
1
0.3.11
0
0.0.0-next-20240131063127
0
0.3.10
1
0.3.9
0
0.3.8
0
0.3.7
1
0.3.6
1
0.3.5
0
0.3.4
92
0.3.3
1
0.0.0-nightly-20240114070311
0
0.3.2
0
0.0.0-next-20240112061202
1
0.3.11
0.3.0
1
0.0.0-next-20240109105933
0
0.0.0-next-20240109045121
0
0.2.18
0
0.2.17
1
0.2.16
0
0.0.0-next-20240104101129
0
0.2.15
0
0.2.14
1
0.2.13
1
0.2.12
0
0.2.11
0
0.2.10
0
0.2.9
0
0.2.8
0
0.0.0-next-20231220091832
0
0.2.70
0.2.6
0
0.2.5
0
0.2.4
0
0.2.3
0
0.2.2
1
0.2.1
0
0.2.0
0
0.0.0-next-20231207110454
0
0.1.9
1
0.1.8
0
0.1.7
1
0.1.6
0
0.1.5
0
0.1.4
1
0.1.3
1
0.1.2
0
0.1.1
1
0.1.0
1
0.0.28
0
0.0.27
2
0.0.26
0
0.0.25
0
0.0.24
0
0.0.23
1
0.0.0-next-20231115072032
0
0.0.22
0
0.0.21
1
0.0.0-nightly-20231112160816
0
0.0.0-nightly-20231111160817
1
0.0.20
0
0.0.0-nightly-20231110160815
1
0.0.19
1
0.0.0-nightly-20231109160811
0
0.0.18
0
0.0.0-nightly-20231108160845
0
0.0.17
0
0.0.0-next-20231108034054
0
0.0.0-nightly-20231107160817
1
0.0.16
1
0.0.0-nightly-20231106161004
0
0.0.15
0
0.0.0-nightly-20231105160803
1
0.0.14
0
0.0.0-nightly-20231104160802
0
0.0.0-nightly-20231103160938
1
0.0.13
1
0.0.0-next-20231103091827
0
0.0.0-nightly-20231102160941
1
0.0.0-nightly-20231101160938
1

Package Sidebar

Install

npm i @rsbuild/plugin-css-minimizer

Weekly Downloads

25,411

Version

1.0.2

License

MIT

Unpacked Size

12 kB

Total Files

7

Last publish

Collaborators

  • chenjiahan
  • hardfist