@rsbuild/plugin-tailwindcss 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,21 +1,18 @@
1
1
  import type { RsbuildPlugin } from '@rsbuild/core';
2
- export declare const PLUGIN_TAILWINDCSS_NAME = "rsbuild:tailwindcss";
2
+ export declare const PLUGIN_TAILWINDCSS_NAME = 'rsbuild:tailwindcss';
3
3
  export type PluginTailwindcssOptions = {
4
4
  /**
5
- * Enable Tailwind CSS's built-in Lightning CSS optimization.
6
- *
7
- * This overlaps with Rsbuild's built-in Lightning CSS optimization. It is
8
- * recommended to enable this option only when Rsbuild's built-in Lightning
9
- * CSS optimization is disabled.
10
- *
11
- * @default false
12
- */
13
- optimize?: boolean | {
5
+ * Enable Tailwind CSS's built-in Lightning CSS optimization.
6
+ *
7
+ * By default, this is enabled in production mode and disabled in development
8
+ * mode. Minification follows Rsbuild's CSS minification config.
9
+ *
10
+ * @default true in production mode, false in development mode
11
+ */ optimize?: boolean | {
14
12
  /**
15
13
  * Enable minification in Tailwind CSS's built-in Lightning CSS optimization.
16
- * @default false
17
- */
18
- minify?: boolean;
14
+ * @default Follows Rsbuild's CSS minification config.
15
+ */ minify?: boolean;
19
16
  };
20
17
  };
21
18
  export declare const pluginTailwindcss: (options?: PluginTailwindcssOptions) => RsbuildPlugin;
package/dist/index.js CHANGED
@@ -2,11 +2,18 @@ import { createRequire } from "node:module";
2
2
  let src_require = createRequire(import.meta.url), PLUGIN_TAILWINDCSS_NAME = 'rsbuild:tailwindcss', pluginTailwindcss = (options = {})=>({
3
3
  name: PLUGIN_TAILWINDCSS_NAME,
4
4
  setup (api) {
5
- api.modifyBundlerChain((chain, { CHAIN_ID, environment, target })=>{
5
+ api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd, target })=>{
6
6
  if (!chain.module.rules.has(CHAIN_ID.RULE.CSS)) return;
7
- let { output } = environment.config, tailwindOptions = {
7
+ let { output } = environment.config, { optimize } = options;
8
+ if (void 0 === optimize) if (isProd) {
9
+ var minify;
10
+ optimize = {
11
+ minify: (minify = output.minify, 'boolean' == typeof minify || void 0 === minify ? (minify ?? !0) && isProd : !1 !== minify.css && ('always' === minify.css || isProd))
12
+ };
13
+ } else optimize = !1;
14
+ let tailwindOptions = {
8
15
  base: api.context.rootPath,
9
- optimize: options.optimize ?? !1
16
+ optimize
10
17
  }, emitCss = output.emitCss ?? 'web' === target, addTailwindLoader = (rule)=>{
11
18
  ((rule, cssUseId)=>{
12
19
  if (!rule.uses.has(cssUseId)) return;
package/package.json CHANGED
@@ -1,33 +1,37 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-tailwindcss",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Tailwind CSS plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.rs",
6
+ "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "https://github.com/web-infra-dev/rsbuild",
9
10
  "directory": "packages/plugin-tailwindcss"
10
11
  },
11
- "license": "MIT",
12
+ "files": [
13
+ "dist"
14
+ ],
12
15
  "type": "module",
16
+ "types": "./dist/index.d.ts",
13
17
  "exports": {
14
18
  ".": {
15
19
  "types": "./dist/index.d.ts",
16
20
  "default": "./dist/index.js"
17
21
  }
18
22
  },
19
- "types": "./dist/index.d.ts",
20
- "files": [
21
- "dist"
22
- ],
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org/"
26
+ },
23
27
  "dependencies": {
24
28
  "@tailwindcss/webpack": "^4.3.0"
25
29
  },
26
30
  "devDependencies": {
27
- "@rslib/core": "0.21.5",
28
- "@types/node": "^24.12.4",
31
+ "@rslib/core": "0.22.0",
32
+ "@types/node": "^24.13.1",
29
33
  "typescript": "^6.0.3",
30
- "@rsbuild/core": "2.0.7",
34
+ "@rsbuild/core": "2.0.11",
31
35
  "@scripts/test-helper": "1.0.0"
32
36
  },
33
37
  "peerDependencies": {
@@ -38,10 +42,6 @@
38
42
  "optional": true
39
43
  }
40
44
  },
41
- "publishConfig": {
42
- "access": "public",
43
- "registry": "https://registry.npmjs.org/"
44
- },
45
45
  "scripts": {
46
46
  "build": "rslib",
47
47
  "dev": "rslib -w"