diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-11-24 20:54:57 +0100 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-11-24 20:57:48 +0100 |
| commit | b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch) | |
| tree | 49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/tailwindcss/src/oxide/cli/build/index.ts | |
Docs
Diffstat (limited to 'node_modules/tailwindcss/src/oxide/cli/build/index.ts')
| -rw-r--r-- | node_modules/tailwindcss/src/oxide/cli/build/index.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/node_modules/tailwindcss/src/oxide/cli/build/index.ts b/node_modules/tailwindcss/src/oxide/cli/build/index.ts new file mode 100644 index 0000000..ba7c874 --- /dev/null +++ b/node_modules/tailwindcss/src/oxide/cli/build/index.ts @@ -0,0 +1,47 @@ +import fs from 'fs' +import path from 'path' +import { resolveDefaultConfigPath } from '../../../util/resolveConfigPath' +import { createProcessor } from './plugin' + +export async function build(args) { + let input = args['--input'] + let shouldWatch = args['--watch'] + + // TODO: Deprecate this in future versions + if (!input && args['_'][1]) { + console.error('[deprecation] Running tailwindcss without -i, please provide an input file.') + input = args['--input'] = args['_'][1] + } + + if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) { + console.error(`Specified input file ${args['--input']} does not exist.`) + process.exit(9) + } + + if (args['--config'] && !fs.existsSync((args['--config'] = path.resolve(args['--config'])))) { + console.error(`Specified config file ${args['--config']} does not exist.`) + process.exit(9) + } + + // TODO: Reference the @config path here if exists + let configPath = args['--config'] ? args['--config'] : resolveDefaultConfigPath() + + let processor = await createProcessor(args, configPath) + + if (shouldWatch) { + // Abort the watcher if stdin is closed to avoid zombie processes + // You can disable this behavior with --watch=always + if (args['--watch'] !== 'always') { + process.stdin.on('end', () => process.exit(0)) + } + + process.stdin.resume() + + await processor.watch() + } else { + await processor.build().catch((e) => { + console.error(e) + process.exit(1) + }) + } +} |