refactor to use single options object

This commit is contained in:
Erin 2023-07-28 04:49:34 -04:00
parent da9edb17b7
commit 8bc53613b0

View file

@ -3,7 +3,11 @@
import {readFileSync} from 'node:fs';
import {resolve, basename, extname, dirname, relative, join} from 'node:path';
export function createConfig (manifestPathRelative, options, createConfig) {
export function createConfig ({
manifest: manifestPathRelative,
scriptPlugins = [],
sourcemap,
}) {
const manifestPath = resolve(process.cwd(), manifestPathRelative);
const manifestDirname = dirname(manifestPath);
@ -109,15 +113,13 @@ export function createConfig (manifestPathRelative, options, createConfig) {
const platform = 'firefox';
return [
...scripts.map(entrypointPath => ({
// Get configuration options for this entrypoint from the caller
...createConfig(),
// Overwrite input and output options
input: relative(process.cwd(), entrypointPath),
output: {
file: getOutputPathRelative('build', platform, entrypointPath, 'js'),
format: 'iife',
sourcemap: options.sourcemap,
sourcemap,
},
plugins: scriptPlugins,
})),
// A special step that processes the manifest and copies over non-JS