feat(build): implement dist and src paths customization

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