@10up/build 1.0.0-alpha.1

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.
Files changed (56) hide show
  1. package/README.md +508 -0
  2. package/bin/10up-build.js +11 -0
  3. package/config/postcss.config.js +36 -0
  4. package/dist/build.d.ts +11 -0
  5. package/dist/build.d.ts.map +1 -0
  6. package/dist/build.js +315 -0
  7. package/dist/build.js.map +1 -0
  8. package/dist/cli.d.ts +8 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +122 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/config.d.ts +103 -0
  13. package/dist/config.d.ts.map +1 -0
  14. package/dist/config.js +230 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/index.d.ts +18 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +20 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/plugins/block-json.d.ts +18 -0
  21. package/dist/plugins/block-json.d.ts.map +1 -0
  22. package/dist/plugins/block-json.js +172 -0
  23. package/dist/plugins/block-json.js.map +1 -0
  24. package/dist/plugins/copy-assets.d.ts +15 -0
  25. package/dist/plugins/copy-assets.d.ts.map +1 -0
  26. package/dist/plugins/copy-assets.js +62 -0
  27. package/dist/plugins/copy-assets.js.map +1 -0
  28. package/dist/plugins/sass-plugin.d.ts +17 -0
  29. package/dist/plugins/sass-plugin.d.ts.map +1 -0
  30. package/dist/plugins/sass-plugin.js +163 -0
  31. package/dist/plugins/sass-plugin.js.map +1 -0
  32. package/dist/plugins/wp-dependency-extraction.d.ts +27 -0
  33. package/dist/plugins/wp-dependency-extraction.d.ts.map +1 -0
  34. package/dist/plugins/wp-dependency-extraction.js +306 -0
  35. package/dist/plugins/wp-dependency-extraction.js.map +1 -0
  36. package/dist/types.d.ts +540 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +12 -0
  39. package/dist/types.js.map +1 -0
  40. package/dist/utils/entry-detection.d.ts +13 -0
  41. package/dist/utils/entry-detection.d.ts.map +1 -0
  42. package/dist/utils/entry-detection.js +218 -0
  43. package/dist/utils/entry-detection.js.map +1 -0
  44. package/dist/utils/externals.d.ts +62 -0
  45. package/dist/utils/externals.d.ts.map +1 -0
  46. package/dist/utils/externals.js +152 -0
  47. package/dist/utils/externals.js.map +1 -0
  48. package/dist/utils/paths.d.ts +40 -0
  49. package/dist/utils/paths.d.ts.map +1 -0
  50. package/dist/utils/paths.js +70 -0
  51. package/dist/utils/paths.js.map +1 -0
  52. package/dist/watch.d.ts +13 -0
  53. package/dist/watch.d.ts.map +1 -0
  54. package/dist/watch.js +214 -0
  55. package/dist/watch.js.map +1 -0
  56. package/package.json +73 -0
package/dist/build.js ADDED
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Main build orchestration for 10up-build
3
+ */
4
+ import { mkdirSync, rmSync, existsSync } from 'node:fs';
5
+ // path imports used in type annotations
6
+ import * as esbuild from 'esbuild';
7
+ import pc from 'picocolors';
8
+ import { loadConfig, getOutputDir, isProduction } from './config.js';
9
+ import { detectEntries, getBlockSpecificStyles } from './utils/entry-detection.js';
10
+ import { wpDependencyExtractionPlugin, clearDependencies } from './plugins/wp-dependency-extraction.js';
11
+ import { sassPlugin } from './plugins/sass-plugin.js';
12
+ import { processBlockJsonFiles } from './plugins/block-json.js';
13
+ import { copyStaticAssets } from './plugins/copy-assets.js';
14
+ import { getExternalPatterns } from './utils/externals.js';
15
+ /**
16
+ * Profile enabled via environment variable
17
+ */
18
+ const PROFILE_ENABLED = process.env.BUILD_PROFILE === '1' || process.env.BUILD_PROFILE === 'true';
19
+ /**
20
+ * Get common esbuild options
21
+ */
22
+ function getCommonOptions(config, outputDir, isProd) {
23
+ // Get external patterns for WordPress and vendor packages
24
+ const external = config.wpDependencyExternals ? getExternalPatterns(config) : [];
25
+ return {
26
+ bundle: true,
27
+ metafile: true,
28
+ sourcemap: config.sourcemap || !isProd,
29
+ minify: isProd,
30
+ target: ['es2020'],
31
+ external,
32
+ loader: {
33
+ '.js': 'jsx',
34
+ '.ts': 'tsx',
35
+ '.tsx': 'tsx',
36
+ '.jsx': 'jsx',
37
+ },
38
+ jsx: 'automatic',
39
+ logLevel: 'warning',
40
+ outdir: outputDir,
41
+ // Set working directory explicitly to ensure consistent path resolution
42
+ absWorkingDir: process.cwd(),
43
+ };
44
+ }
45
+ /**
46
+ * Build JavaScript/TypeScript entries
47
+ */
48
+ async function buildScripts(entries, config, outputDir, isProd) {
49
+ if (Object.keys(entries).length === 0) {
50
+ return null;
51
+ }
52
+ // Clear previous dependency tracking
53
+ clearDependencies();
54
+ const result = await esbuild.build({
55
+ ...getCommonOptions(config, outputDir, isProd),
56
+ entryPoints: entries,
57
+ format: 'iife',
58
+ globalName: '__tenupBuild',
59
+ plugins: [
60
+ wpDependencyExtractionPlugin(config),
61
+ sassPlugin(config, isProd),
62
+ ],
63
+ outExtension: { '.js': '.js' },
64
+ entryNames: '[dir]/[name]',
65
+ chunkNames: 'js/chunks/[name]-[hash]',
66
+ assetNames: 'assets/[name]-[hash]',
67
+ write: true,
68
+ });
69
+ return result;
70
+ }
71
+ /**
72
+ * Build ES Module entries
73
+ */
74
+ async function buildModules(entries, config, outputDir, isProd) {
75
+ if (Object.keys(entries).length === 0) {
76
+ return null;
77
+ }
78
+ // Clear previous dependency tracking
79
+ clearDependencies();
80
+ const result = await esbuild.build({
81
+ ...getCommonOptions(config, outputDir, isProd),
82
+ entryPoints: entries,
83
+ format: 'esm',
84
+ splitting: true,
85
+ plugins: [
86
+ wpDependencyExtractionPlugin(config),
87
+ sassPlugin(config, isProd),
88
+ ],
89
+ outExtension: { '.js': '.mjs' },
90
+ entryNames: '[dir]/[name]',
91
+ chunkNames: 'js/chunks/[name]-[hash]',
92
+ assetNames: 'assets/[name]-[hash]',
93
+ write: true,
94
+ });
95
+ return result;
96
+ }
97
+ /**
98
+ * Build standalone CSS entries
99
+ */
100
+ async function buildStyles(entries, config, outputDir, isProd) {
101
+ if (Object.keys(entries).length === 0) {
102
+ return null;
103
+ }
104
+ const result = await esbuild.build({
105
+ ...getCommonOptions(config, outputDir, isProd),
106
+ entryPoints: entries,
107
+ plugins: [sassPlugin(config, isProd)],
108
+ outExtension: { '.js': '.js', '.css': '.css' },
109
+ entryNames: '[dir]/[name]',
110
+ write: true,
111
+ // CSS-only builds still create empty JS files, we'll clean them up
112
+ bundle: true,
113
+ });
114
+ return result;
115
+ }
116
+ /**
117
+ * Clean output directory
118
+ */
119
+ function cleanOutputDir(outputDir) {
120
+ if (existsSync(outputDir)) {
121
+ rmSync(outputDir, { recursive: true, force: true });
122
+ }
123
+ mkdirSync(outputDir, { recursive: true });
124
+ }
125
+ /**
126
+ * Format duration for display
127
+ */
128
+ function formatDuration(ms) {
129
+ if (ms < 1000) {
130
+ return `${ms.toFixed(0)}ms`;
131
+ }
132
+ return `${(ms / 1000).toFixed(2)}s`;
133
+ }
134
+ /**
135
+ * Format profile duration with padding for alignment
136
+ */
137
+ function formatProfileDuration(ms, total) {
138
+ const percentage = total > 0 ? ((ms / total) * 100).toFixed(1) : '0.0';
139
+ const duration = formatDuration(ms);
140
+ return `${duration.padStart(8)} ${pc.dim(`(${percentage.padStart(5)}%)`)}`;
141
+ }
142
+ /**
143
+ * Print build profile report
144
+ */
145
+ function printProfile(profile) {
146
+ console.log(pc.cyan('\n┌─ Build Profile ─────────────────────────┐'));
147
+ const phases = [
148
+ { name: 'Config loading', time: profile.configLoad },
149
+ { name: 'Entry detection', time: profile.entryDetection },
150
+ { name: 'Clean output', time: profile.cleanOutput },
151
+ { name: 'Scripts (IIFE)', time: profile.scripts },
152
+ { name: 'Modules (ESM)', time: profile.modules },
153
+ { name: 'Styles (CSS)', time: profile.styles },
154
+ { name: 'Block JSON', time: profile.blockJson },
155
+ { name: 'Asset copy', time: profile.assetCopy },
156
+ ];
157
+ for (const phase of phases) {
158
+ if (phase.time > 0) {
159
+ const bar = getProgressBar(phase.time, profile.total, 15);
160
+ console.log(pc.dim('│ ') +
161
+ phase.name.padEnd(16) +
162
+ formatProfileDuration(phase.time, profile.total) +
163
+ ' ' +
164
+ bar);
165
+ }
166
+ }
167
+ console.log(pc.dim('├──────────────────────────────────────────┤'));
168
+ console.log(pc.dim('│ ') + pc.bold('Total'.padEnd(16)) + formatProfileDuration(profile.total, profile.total));
169
+ console.log(pc.cyan('└──────────────────────────────────────────┘\n'));
170
+ }
171
+ /**
172
+ * Generate a simple progress bar
173
+ */
174
+ function getProgressBar(value, total, width) {
175
+ const percentage = total > 0 ? value / total : 0;
176
+ const filled = Math.round(percentage * width);
177
+ const empty = width - filled;
178
+ return pc.cyan('█'.repeat(filled)) + pc.dim('░'.repeat(empty));
179
+ }
180
+ /**
181
+ * Main build function
182
+ */
183
+ export async function build(customConfig) {
184
+ const startTime = performance.now();
185
+ const profile = {
186
+ configLoad: 0,
187
+ entryDetection: 0,
188
+ cleanOutput: 0,
189
+ scripts: 0,
190
+ modules: 0,
191
+ styles: 0,
192
+ blockJson: 0,
193
+ assetCopy: 0,
194
+ total: 0,
195
+ };
196
+ // Config loading
197
+ let phaseStart = performance.now();
198
+ const config = { ...loadConfig(), ...customConfig };
199
+ const outputDir = getOutputDir(config);
200
+ const isProd = isProduction();
201
+ profile.configLoad = performance.now() - phaseStart;
202
+ console.log(pc.cyan('\n10up-build') + pc.dim(` v1.0.0`));
203
+ console.log(pc.dim(`Mode: ${isProd ? 'production' : 'development'}\n`));
204
+ try {
205
+ // Clean output directory
206
+ phaseStart = performance.now();
207
+ cleanOutputDir(outputDir);
208
+ profile.cleanOutput = performance.now() - phaseStart;
209
+ // Detect all entry points
210
+ phaseStart = performance.now();
211
+ const entries = await detectEntries(config);
212
+ // Add block-specific styles if enabled
213
+ if (config.loadBlockSpecificStyles) {
214
+ const blockStyles = getBlockSpecificStyles(config);
215
+ Object.assign(entries.styles, blockStyles);
216
+ }
217
+ profile.entryDetection = performance.now() - phaseStart;
218
+ const totalEntries = Object.keys(entries.scripts).length +
219
+ Object.keys(entries.modules).length +
220
+ Object.keys(entries.styles).length;
221
+ if (totalEntries === 0) {
222
+ console.log(pc.yellow('No entry points found.'));
223
+ return {
224
+ success: true,
225
+ duration: performance.now() - startTime,
226
+ entries: { scripts: 0, modules: 0, styles: 0 },
227
+ };
228
+ }
229
+ console.log(pc.dim(`Building ${totalEntries} entries...\n`));
230
+ // Build in parallel, tracking individual times
231
+ const buildPromises = [];
232
+ // Scripts
233
+ if (Object.keys(entries.scripts).length > 0) {
234
+ buildPromises.push((async () => {
235
+ const start = performance.now();
236
+ await buildScripts(entries.scripts, config, outputDir, isProd);
237
+ profile.scripts = performance.now() - start;
238
+ })());
239
+ }
240
+ // Modules
241
+ if (Object.keys(entries.modules).length > 0) {
242
+ buildPromises.push((async () => {
243
+ const start = performance.now();
244
+ await buildModules(entries.modules, config, outputDir, isProd);
245
+ profile.modules = performance.now() - start;
246
+ })());
247
+ }
248
+ // Styles
249
+ if (Object.keys(entries.styles).length > 0) {
250
+ buildPromises.push((async () => {
251
+ const start = performance.now();
252
+ await buildStyles(entries.styles, config, outputDir, isProd);
253
+ profile.styles = performance.now() - start;
254
+ })());
255
+ }
256
+ await Promise.all(buildPromises);
257
+ // Process block.json files
258
+ phaseStart = performance.now();
259
+ if (config.useBlockAssets) {
260
+ await processBlockJsonFiles(config, outputDir);
261
+ }
262
+ profile.blockJson = performance.now() - phaseStart;
263
+ // Copy static assets
264
+ phaseStart = performance.now();
265
+ const assetCount = await copyStaticAssets(config, outputDir);
266
+ profile.assetCopy = performance.now() - phaseStart;
267
+ // Report results
268
+ const scriptsCount = Object.keys(entries.scripts).length;
269
+ const modulesCount = Object.keys(entries.modules).length;
270
+ const stylesCount = Object.keys(entries.styles).length;
271
+ if (scriptsCount > 0) {
272
+ console.log(pc.green('✓') + pc.dim(` Scripts: ${scriptsCount} entries`));
273
+ }
274
+ if (modulesCount > 0) {
275
+ console.log(pc.green('✓') + pc.dim(` Modules: ${modulesCount} entries`));
276
+ }
277
+ if (stylesCount > 0) {
278
+ console.log(pc.green('✓') + pc.dim(` Styles: ${stylesCount} entries`));
279
+ }
280
+ if (assetCount > 0) {
281
+ console.log(pc.green('✓') + pc.dim(` Assets: ${assetCount} files copied`));
282
+ }
283
+ const duration = performance.now() - startTime;
284
+ profile.total = duration;
285
+ console.log(pc.green(`\n✓ Done in ${formatDuration(duration)}`));
286
+ // Print profile if enabled
287
+ if (PROFILE_ENABLED) {
288
+ printProfile(profile);
289
+ }
290
+ return {
291
+ success: true,
292
+ duration,
293
+ entries: {
294
+ scripts: scriptsCount,
295
+ modules: modulesCount,
296
+ styles: stylesCount,
297
+ },
298
+ };
299
+ }
300
+ catch (error) {
301
+ const duration = performance.now() - startTime;
302
+ console.error(pc.red('\n✗ Build failed'));
303
+ if (error instanceof Error) {
304
+ console.error(pc.red(error.message));
305
+ }
306
+ return {
307
+ success: false,
308
+ duration,
309
+ entries: { scripts: 0, modules: 0, styles: 0 },
310
+ errors: [error instanceof Error ? error.message : String(error)],
311
+ };
312
+ }
313
+ }
314
+ export { loadConfig, getOutputDir, isProduction };
315
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACxD,wCAAwC;AACxC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,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C"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CLI for 10up-build
3
+ */
4
+ /**
5
+ * Main CLI entry point
6
+ */
7
+ export declare function cli(args: string[]): Promise<void>;
8
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkGH;;GAEG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BvD"}
package/dist/cli.js ADDED
@@ -0,0 +1,122 @@
1
+ /**
2
+ * CLI for 10up-build
3
+ */
4
+ import pc from 'picocolors';
5
+ import { build } from './build.js';
6
+ import { watch } from './watch.js';
7
+ /**
8
+ * Parse CLI arguments
9
+ */
10
+ function parseArgs(args) {
11
+ const flags = {};
12
+ let command = 'build';
13
+ for (const arg of args) {
14
+ if (arg.startsWith('--')) {
15
+ const [key, value] = arg.slice(2).split('=');
16
+ flags[key] = value ?? true;
17
+ }
18
+ else if (arg.startsWith('-')) {
19
+ flags[arg.slice(1)] = true;
20
+ }
21
+ else if (!command || command === 'build') {
22
+ // First non-flag argument is the command
23
+ command = arg;
24
+ }
25
+ }
26
+ return { command, flags };
27
+ }
28
+ /**
29
+ * Show help message
30
+ */
31
+ function showHelp() {
32
+ console.log(`
33
+ ${pc.cyan('10up-build')} - Fast WordPress build tool powered by esbuild
34
+
35
+ ${pc.bold('Usage:')}
36
+ 10up-build <command> [options]
37
+
38
+ ${pc.bold('Commands:')}
39
+ build Build for production (default)
40
+ start Start development mode with watch and hot reload
41
+ watch Watch for changes without hot reload
42
+
43
+ ${pc.bold('Options:')}
44
+ --help, -h Show this help message
45
+ --version, -v Show version number
46
+ --hot Enable hot reload (default in start mode)
47
+ --port=<port> HMR server port (default: 8887)
48
+
49
+ ${pc.bold('Configuration:')}
50
+ Configure via package.json "10up-toolkit" field.
51
+ See documentation for all options.
52
+
53
+ ${pc.bold('Examples:')}
54
+ 10up-build # Production build
55
+ 10up-build start # Development with hot reload
56
+ 10up-build watch # Watch without hot reload
57
+ 10up-build build --sourcemap
58
+ `);
59
+ }
60
+ /**
61
+ * Show version
62
+ */
63
+ function showVersion() {
64
+ console.log('10up-build v1.0.0-alpha.1');
65
+ }
66
+ /**
67
+ * Command handlers
68
+ */
69
+ const commands = {
70
+ build: async (_args) => {
71
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production';
72
+ const result = await build();
73
+ process.exit(result.success ? 0 : 1);
74
+ },
75
+ start: async (args) => {
76
+ process.env.NODE_ENV = 'development';
77
+ const { flags } = parseArgs(['start', ...args]);
78
+ await watch({
79
+ hot: true,
80
+ port: flags.port ? parseInt(String(flags.port), 10) : undefined,
81
+ });
82
+ },
83
+ watch: async (args) => {
84
+ process.env.NODE_ENV = 'development';
85
+ const { flags } = parseArgs(['watch', ...args]);
86
+ await watch({
87
+ hot: flags.hot === true,
88
+ port: flags.port ? parseInt(String(flags.port), 10) : undefined,
89
+ });
90
+ },
91
+ };
92
+ /**
93
+ * Main CLI entry point
94
+ */
95
+ export async function cli(args) {
96
+ const { command, flags } = parseArgs(args);
97
+ // Handle help flag
98
+ if (flags.help || flags.h) {
99
+ showHelp();
100
+ return;
101
+ }
102
+ // Handle version flag
103
+ if (flags.version || flags.v) {
104
+ showVersion();
105
+ return;
106
+ }
107
+ // Get command handler
108
+ const handler = commands[command];
109
+ if (!handler) {
110
+ console.error(pc.red(`Unknown command: ${command}`));
111
+ console.log(pc.dim('Run "10up-build --help" for usage information.'));
112
+ process.exit(1);
113
+ }
114
+ try {
115
+ await handler(args.slice(1));
116
+ }
117
+ catch (error) {
118
+ console.error(pc.red('Error:'), error instanceof Error ? error.message : error);
119
+ process.exit(1);
120
+ }
121
+ }
122
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[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CAAC;AACF,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Configuration loading for @10up/build
3
+ *
4
+ * This module handles loading and merging configuration from multiple sources:
5
+ * 1. Default configuration values
6
+ * 2. `package.json["10up-toolkit"]` field
7
+ * 3. Configuration files (buildfiles.config.js, postcss.config.js)
8
+ *
9
+ * @packageDocumentation
10
+ * @module config
11
+ */
12
+ import type { BuildConfig } from './types.js';
13
+ /**
14
+ * Default configuration values.
15
+ *
16
+ * These values are used when not overridden by user configuration.
17
+ * The configuration schema is designed to be compatible with
18
+ * 10up-toolkit's configuration format.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { defaultConfig } from '@10up/build/config';
23
+ * console.log(defaultConfig.wpDependencyExternals); // true
24
+ * ```
25
+ */
26
+ export declare const defaultConfig: BuildConfig;
27
+ /**
28
+ * Load and merge configuration from all sources.
29
+ *
30
+ * Configuration is loaded in the following order (later sources override earlier):
31
+ * 1. Default configuration
32
+ * 2. `package.json["10up-toolkit"]` field
33
+ * 3. PostCSS configuration file detection
34
+ *
35
+ * @returns Merged build configuration
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { loadConfig } from '@10up/build';
40
+ *
41
+ * const config = loadConfig();
42
+ * console.log(config.paths.blocksDir); // "./includes/blocks/"
43
+ * ```
44
+ */
45
+ export declare function loadConfig(): BuildConfig;
46
+ /**
47
+ * Check if a configuration file exists in the project root.
48
+ *
49
+ * @param filename - Name of the configuration file to check
50
+ * @returns True if the file exists
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * if (hasConfigFile('postcss.config.js')) {
55
+ * console.log('Using custom PostCSS configuration');
56
+ * }
57
+ * ```
58
+ */
59
+ export declare function hasConfigFile(filename: string): boolean;
60
+ /**
61
+ * Get the output directory path.
62
+ *
63
+ * Returns the absolute path to the dist directory where
64
+ * compiled assets will be written.
65
+ *
66
+ * @param config - Build configuration
67
+ * @returns Absolute path to the output directory
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const outputDir = getOutputDir(config);
72
+ * console.log(outputDir); // "/path/to/project/dist"
73
+ * ```
74
+ */
75
+ export declare function getOutputDir(config: BuildConfig): string;
76
+ /**
77
+ * Check if the build is running in production mode.
78
+ *
79
+ * Production mode is determined by `NODE_ENV=production`.
80
+ * In production mode:
81
+ * - Output is minified
82
+ * - Source maps are disabled (unless explicitly enabled)
83
+ * - Console output is optimized
84
+ *
85
+ * @returns True if NODE_ENV is "production"
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * if (isProduction()) {
90
+ * console.log('Building for production...');
91
+ * }
92
+ * ```
93
+ */
94
+ export declare function isProduction(): boolean;
95
+ /**
96
+ * Check if the build is running in watch mode.
97
+ *
98
+ * Watch mode is detected from command-line arguments.
99
+ *
100
+ * @returns True if --watch flag is present or command is "start"
101
+ */
102
+ export declare function isWatchMode(): boolean;
103
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,WAAW,EAA+C,MAAM,YAAY,CAAC;AA+B3F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,EAAE,WA4B3B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,IAAI,WAAW,CA4BxC;AAoDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAExD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC"}