add outDir option
This commit is contained in:
parent
12ace068f2
commit
95519137f5
15
index.mjs
15
index.mjs
|
@ -6,6 +6,7 @@ import {resolve, basename, extname, dirname, relative, join} from 'node:path';
|
||||||
export function buildConfig ({
|
export function buildConfig ({
|
||||||
manifest: manifestPathRelative,
|
manifest: manifestPathRelative,
|
||||||
platforms = [],
|
platforms = [],
|
||||||
|
outDir = 'build/[platform]',
|
||||||
scriptPlugins = [],
|
scriptPlugins = [],
|
||||||
sourcemap,
|
sourcemap,
|
||||||
}) {
|
}) {
|
||||||
|
@ -51,10 +52,6 @@ export function buildConfig ({
|
||||||
return join(base, uniqueFileNameSegment(entryPath, ext));
|
return join(base, uniqueFileNameSegment(entryPath, ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOutputPathRelative (outputDir, platform, entryPath, ext) {
|
|
||||||
return join(outputDir, platform, getOutputFilename(entryPath, ext));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Scans a manifest for entrypoints */
|
/** Scans a manifest for entrypoints */
|
||||||
function getEntryPointsFromManifest (manifestContent) {
|
function getEntryPointsFromManifest (manifestContent) {
|
||||||
const scriptEntrypointAbsolutePaths = [];
|
const scriptEntrypointAbsolutePaths = [];
|
||||||
|
@ -119,7 +116,10 @@ export function buildConfig ({
|
||||||
...scripts.map(entrypointPath => ({
|
...scripts.map(entrypointPath => ({
|
||||||
input: relative(process.cwd(), entrypointPath),
|
input: relative(process.cwd(), entrypointPath),
|
||||||
output: {
|
output: {
|
||||||
file: getOutputPathRelative('build', platform, entrypointPath, 'js'),
|
file: join(
|
||||||
|
outDir.replace(/\[platform\]/g, platform),
|
||||||
|
getOutputFilename(entrypointPath, 'js'),
|
||||||
|
),
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
sourcemap,
|
sourcemap,
|
||||||
},
|
},
|
||||||
|
@ -131,7 +131,10 @@ export function buildConfig ({
|
||||||
{
|
{
|
||||||
input: manifestPathRelative,
|
input: manifestPathRelative,
|
||||||
output: {
|
output: {
|
||||||
file: `build/${platform}/manifest.json`,
|
file: join(
|
||||||
|
outDir.replace(/\[platform\]/g, platform),
|
||||||
|
`manifest.json`
|
||||||
|
),
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue