2022-03-16 07:50:12 +00:00
|
|
|
import { BuildEntry, defineBuildConfig } from 'unbuild';
|
|
|
|
import packageJSON from './package.json';
|
|
|
|
|
|
|
|
const entries: BuildEntry[] = [];
|
|
|
|
const exportsList = packageJSON['exports'];
|
|
|
|
const match = './lib/';
|
|
|
|
|
|
|
|
Object.keys(exportsList).forEach((key) => {
|
|
|
|
if (key.slice(0, match.length) !== match) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const importValue = exportsList[key]['import'];
|
|
|
|
if (importValue === key + '.mjs') {
|
|
|
|
const name = key.slice(match.length);
|
|
|
|
entries.push({
|
|
|
|
input: 'src/' + name,
|
|
|
|
name,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2022-03-02 20:11:50 +00:00
|
|
|
|
|
|
|
export default defineBuildConfig({
|
2022-03-02 20:33:10 +00:00
|
|
|
outDir: './lib',
|
2022-03-16 07:50:12 +00:00
|
|
|
entries,
|
2022-03-02 20:11:50 +00:00
|
|
|
clean: true,
|
|
|
|
declaration: true,
|
|
|
|
rollup: {
|
|
|
|
emitCJS: true,
|
|
|
|
},
|
2022-03-16 07:50:12 +00:00
|
|
|
});
|