add platforms option

platform stuff is still mostly special cased but
This commit is contained in:
Erin 2023-07-28 04:55:46 -04:00
parent b0356988fe
commit 12ace068f2

View file

@ -5,12 +5,17 @@ import {resolve, basename, extname, dirname, relative, join} from 'node:path';
export function buildConfig ({ export function buildConfig ({
manifest: manifestPathRelative, manifest: manifestPathRelative,
platforms = [],
scriptPlugins = [], scriptPlugins = [],
sourcemap, sourcemap,
}) { }) {
const manifestPath = resolve(process.cwd(), manifestPathRelative); const manifestPath = resolve(process.cwd(), manifestPathRelative);
const manifestDirname = dirname(manifestPath); const manifestDirname = dirname(manifestPath);
if (!platforms.length) {
throw new Error('No platforms specified');
}
// Load the manifest // Load the manifest
let manifestContent; let manifestContent;
try { try {
@ -110,8 +115,7 @@ export function buildConfig ({
const {scripts, styles, assets} = getEntryPointsFromManifest(manifestContent); const {scripts, styles, assets} = getEntryPointsFromManifest(manifestContent);
const platform = 'firefox'; return platforms.flatMap(platform => [
return [
...scripts.map(entrypointPath => ({ ...scripts.map(entrypointPath => ({
input: relative(process.cwd(), entrypointPath), input: relative(process.cwd(), entrypointPath),
output: { output: {
@ -165,5 +169,5 @@ export function buildConfig ({
}, },
], ],
}, },
]; ]);
} }