|
1 |
| -import { mkdir, writeFile } from 'node:fs/promises'; |
| 1 | +import { mkdtemp, writeFile } from 'node:fs/promises'; |
| 2 | +import { tmpdir } from 'node:os'; |
2 | 3 | import path from 'node:path';
|
3 | 4 | import { pathToFileURL } from 'node:url';
|
4 | 5 |
|
@@ -184,13 +185,14 @@ class TailwindRspackPluginImpl {
|
184 | 185 | : // biome-ignore lint/style/noNonNullAssertion: should have context
|
185 | 186 | path.resolve(this.compiler.options.context!, this.options.config);
|
186 | 187 |
|
187 |
| - const outputDir = path.resolve( |
188 |
| - // biome-ignore lint/style/noNonNullAssertion: should have `output.path` |
189 |
| - this.compiler.options.output.path!, |
190 |
| - '.rsbuild', |
191 |
| - entryName, |
192 |
| - ); |
193 |
| - await mkdir(outputDir, { recursive: true }); |
| 188 | + const outputDir = DEBUG |
| 189 | + ? path.resolve( |
| 190 | + // biome-ignore lint/style/noNonNullAssertion: should have `output.path` |
| 191 | + this.compiler.options.output.path!, |
| 192 | + '.rsbuild', |
| 193 | + entryName, |
| 194 | + ) |
| 195 | + : await mkdtemp(path.join(tmpdir(), entryName)); |
194 | 196 |
|
195 | 197 | const configPath = path.resolve(outputDir, 'tailwind.config.mjs');
|
196 | 198 |
|
@@ -220,3 +222,14 @@ function collectModules(
|
220 | 222 | entryModules.add(module.resource);
|
221 | 223 | }
|
222 | 224 | }
|
| 225 | + |
| 226 | +const DEBUG = (function isDebug() { |
| 227 | + if (!process.env.DEBUG) { |
| 228 | + return false; |
| 229 | + } |
| 230 | + |
| 231 | + const values = process.env.DEBUG.toLocaleLowerCase().split(','); |
| 232 | + return ['rsbuild', 'rsbuild:tailwind', 'rsbuild:*', '*'].some((key) => |
| 233 | + values.includes(key), |
| 234 | + ); |
| 235 | +})(); |
0 commit comments