refactor to use single options object
This commit is contained in:
parent
da9edb17b7
commit
8bc53613b0
12
index.mjs
12
index.mjs
|
@ -3,7 +3,11 @@
|
||||||
import {readFileSync} from 'node:fs';
|
import {readFileSync} from 'node:fs';
|
||||||
import {resolve, basename, extname, dirname, relative, join} from 'node:path';
|
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 manifestPath = resolve(process.cwd(), manifestPathRelative);
|
||||||
const manifestDirname = dirname(manifestPath);
|
const manifestDirname = dirname(manifestPath);
|
||||||
|
|
||||||
|
@ -109,15 +113,13 @@ export function createConfig (manifestPathRelative, options, createConfig) {
|
||||||
const platform = 'firefox';
|
const platform = 'firefox';
|
||||||
return [
|
return [
|
||||||
...scripts.map(entrypointPath => ({
|
...scripts.map(entrypointPath => ({
|
||||||
// Get configuration options for this entrypoint from the caller
|
|
||||||
...createConfig(),
|
|
||||||
// Overwrite input and output options
|
|
||||||
input: relative(process.cwd(), entrypointPath),
|
input: relative(process.cwd(), entrypointPath),
|
||||||
output: {
|
output: {
|
||||||
file: getOutputPathRelative('build', platform, entrypointPath, 'js'),
|
file: getOutputPathRelative('build', platform, entrypointPath, 'js'),
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
sourcemap: options.sourcemap,
|
sourcemap,
|
||||||
},
|
},
|
||||||
|
plugins: scriptPlugins,
|
||||||
})),
|
})),
|
||||||
|
|
||||||
// A special step that processes the manifest and copies over non-JS
|
// A special step that processes the manifest and copies over non-JS
|
||||||
|
|
Loading…
Reference in a new issue