feat(build): implement dist and src paths customization

This commit is contained in:
2026-08-01 14:08:08 +02:00
committed by jakob.scheid
parent c243bfcf00
commit e810ae9c5b
+22 -6
View File
@@ -20,20 +20,33 @@ import { processPlugin } from './utils/plugin.js';
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
const dir = './build/plugins';
const files = await readdir(dir);
const tryToProcessPlugin = async function tryToProcessPlugin (plugin) {
const tryToProcessPlugin = async function tryToProcessPlugin (plugin, options) {
if (typeof plugin.default === 'function') {
await processPlugin(plugin.default, {
srcBase: './src',
distBase: './dist'
});
await processPlugin(plugin.default, options);
}
};
const { values: args } = parseArgs({
options: {
distBase: {
type: 'string',
short: 'd',
default: './dist/'
},
srcBase: {
type: 'string',
short: 's',
default: './src/'
}
}
});
(await Promise.all(
files
.filter((file) => file.endsWith('.js'))
@@ -41,5 +54,8 @@ const tryToProcessPlugin = async function tryToProcessPlugin (plugin) {
import(pathToFileURL(join(dir, file)).href)
)
)).forEach(
async (plugin) => tryToProcessPlugin(plugin)
async (plugin) => tryToProcessPlugin(plugin, {
srcBase: args.srcBase,
distBase: args.distBase
})
);