From 95519137f5a25432ca0f963fbb15233a7608fbf8 Mon Sep 17 00:00:00 2001 From: Erin Date: Fri, 28 Jul 2023 05:03:32 -0400 Subject: [PATCH] add outDir option --- index.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/index.mjs b/index.mjs index e85a324..843e579 100644 --- a/index.mjs +++ b/index.mjs @@ -6,6 +6,7 @@ import {resolve, basename, extname, dirname, relative, join} from 'node:path'; export function buildConfig ({ manifest: manifestPathRelative, platforms = [], + outDir = 'build/[platform]', scriptPlugins = [], sourcemap, }) { @@ -51,10 +52,6 @@ export function buildConfig ({ return join(base, uniqueFileNameSegment(entryPath, ext)); } - function getOutputPathRelative (outputDir, platform, entryPath, ext) { - return join(outputDir, platform, getOutputFilename(entryPath, ext)); - } - /** Scans a manifest for entrypoints */ function getEntryPointsFromManifest (manifestContent) { const scriptEntrypointAbsolutePaths = []; @@ -119,7 +116,10 @@ export function buildConfig ({ ...scripts.map(entrypointPath => ({ input: relative(process.cwd(), entrypointPath), output: { - file: getOutputPathRelative('build', platform, entrypointPath, 'js'), + file: join( + outDir.replace(/\[platform\]/g, platform), + getOutputFilename(entrypointPath, 'js'), + ), format: 'iife', sourcemap, }, @@ -131,7 +131,10 @@ export function buildConfig ({ { input: manifestPathRelative, output: { - file: `build/${platform}/manifest.json`, + file: join( + outDir.replace(/\[platform\]/g, platform), + `manifest.json` + ), }, plugins: [ {