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));
|
return join(outputDir, platform, getOutputFilename(entryPath, ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Scans a manifest for entrypoints */
|
||||||
|
function getEntryPointsFromManifest (manifestContent) {
|
||||||
const scriptEntrypointAbsolutePaths = [];
|
const scriptEntrypointAbsolutePaths = [];
|
||||||
const styleEntrypointAbsolutePathss = [];
|
const styleEntrypointAbsolutePathss = [];
|
||||||
const otherAssetAbsolutePaths = [];
|
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';
|
const platform = 'firefox';
|
||||||
return [
|
return [
|
||||||
...scriptEntrypointAbsolutePaths.map(entrypointPath => ({
|
...scripts.map(entrypointPath => ({
|
||||||
// Get configuration options for this entrypoint from the caller
|
// Get configuration options for this entrypoint from the caller
|
||||||
...createConfig(),
|
...createConfig(),
|
||||||
// Overwrite input and output options
|
// Overwrite input and output options
|
||||||
|
@ -119,14 +130,14 @@ export function createConfig (manifestPathRelative, options, createConfig) {
|
||||||
plugins: [
|
plugins: [
|
||||||
{
|
{
|
||||||
buildStart () {
|
buildStart () {
|
||||||
styleEntrypointAbsolutePathss.forEach(absolutePath => {
|
styles.forEach(absolutePath => {
|
||||||
this.emitFile({
|
this.emitFile({
|
||||||
type: 'asset',
|
type: 'asset',
|
||||||
fileName: getOutputFilename(absolutePath, 'css'),
|
fileName: getOutputFilename(absolutePath, 'css'),
|
||||||
source: readFileSync(absolutePath, {encoding: 'utf-8'}),
|
source: readFileSync(absolutePath, {encoding: 'utf-8'}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
otherAssetAbsolutePaths.forEach(absolutePath => {
|
assets.forEach(absolutePath => {
|
||||||
// console.log('rendering binary file', absolutePath);
|
// console.log('rendering binary file', absolutePath);
|
||||||
this.emitFile({
|
this.emitFile({
|
||||||
type: 'asset',
|
type: 'asset',
|
||||||
|
|
Loading…
Reference in a new issue