give manifest searching a function
This commit is contained in:
parent
bb79e2a059
commit
cb948b82ba
17
index.mjs
17
index.mjs
|
@ -46,6 +46,8 @@ export function createConfig (manifestPathRelative, options, createConfig) {
|
|||
return join(outputDir, platform, getOutputFilename(entryPath, ext));
|
||||
}
|
||||
|
||||
/** Scans a manifest for entrypoints */
|
||||
function getEntryPointsFromManifest (manifestContent) {
|
||||
const scriptEntrypointAbsolutePaths = [];
|
||||
const styleEntrypointAbsolutePathss = [];
|
||||
const otherAssetAbsolutePaths = [];
|
||||
|
@ -95,9 +97,18 @@ export function createConfig (manifestPathRelative, options, createConfig) {
|
|||
}
|
||||
});
|
||||
|
||||
return {
|
||||
scripts: scriptEntrypointAbsolutePaths,
|
||||
styles: styleEntrypointAbsolutePathss,
|
||||
assets: otherAssetAbsolutePaths,
|
||||
};
|
||||
}
|
||||
|
||||
const {scripts, styles, assets} = getEntryPointsFromManifest(manifestContent);
|
||||
|
||||
const platform = 'firefox';
|
||||
return [
|
||||
...scriptEntrypointAbsolutePaths.map(entrypointPath => ({
|
||||
...scripts.map(entrypointPath => ({
|
||||
// Get configuration options for this entrypoint from the caller
|
||||
...createConfig(),
|
||||
// Overwrite input and output options
|
||||
|
@ -119,14 +130,14 @@ export function createConfig (manifestPathRelative, options, createConfig) {
|
|||
plugins: [
|
||||
{
|
||||
buildStart () {
|
||||
styleEntrypointAbsolutePathss.forEach(absolutePath => {
|
||||
styles.forEach(absolutePath => {
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: getOutputFilename(absolutePath, 'css'),
|
||||
source: readFileSync(absolutePath, {encoding: 'utf-8'}),
|
||||
});
|
||||
});
|
||||
otherAssetAbsolutePaths.forEach(absolutePath => {
|
||||
assets.forEach(absolutePath => {
|
||||
// console.log('rendering binary file', absolutePath);
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
|
|
Loading…
Reference in a new issue