2024-01-02 14:36:10 +08:00
|
|
|
const { resolve, relative, extname } = require('path');
|
|
|
|
const { readdirSync } = require('fs');
|
|
|
|
const typescript = require('@rollup/plugin-typescript');
|
2023-12-19 14:20:48 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {import('rollup').RollupOptions}
|
|
|
|
*/
|
|
|
|
const config = {
|
2024-01-02 14:36:10 +08:00
|
|
|
external: ['jl-graphic'],
|
2024-01-04 10:42:05 +08:00
|
|
|
input: getEntryPoints('src/packages', 'src'),
|
2023-12-19 14:20:48 +08:00
|
|
|
output: {
|
2024-01-02 14:36:10 +08:00
|
|
|
dir: 'components',
|
|
|
|
format: 'esm',
|
2023-12-19 14:20:48 +08:00
|
|
|
preserveModules: true,
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
typescript({
|
2024-01-02 14:36:10 +08:00
|
|
|
tsconfig: './tsconfig.json',
|
2023-12-19 14:20:48 +08:00
|
|
|
compilerOptions: {
|
|
|
|
declaration: true,
|
2024-01-02 14:36:10 +08:00
|
|
|
declarationDir: 'components',
|
2023-12-19 14:20:48 +08:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
module.exports = config;
|
|
|
|
|
2024-01-02 14:36:10 +08:00
|
|
|
function getEntryPoints(dir, root) {
|
|
|
|
let entries = {};
|
|
|
|
const items = readdirSync(dir, { withFileTypes: true });
|
|
|
|
for (const item of items) {
|
|
|
|
const fullPath = resolve(dir, item.name);
|
|
|
|
const relativePath = relative(root, fullPath);
|
|
|
|
const relativeName = relativePath.replace(extname(item.name), '');
|
|
|
|
if (item.isDirectory()) {
|
|
|
|
const subentries = getEntryPoints(fullPath, root);
|
|
|
|
entries = { ...entries, ...subentries };
|
|
|
|
} else {
|
|
|
|
entries[relativeName] = fullPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return entries;
|
2023-12-19 14:20:48 +08:00
|
|
|
}
|