You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.2 KiB
36 lines
1.2 KiB
import path, { resolve } from "node:path";
|
|
import URL from "node:url";
|
|
import fg from "fast-glob";
|
|
import { build } from "unbuild";
|
|
|
|
export async function buildOne(dir: string, isDev: boolean = false) {
|
|
const rootDir = resolve("packages/" + dir);
|
|
|
|
// let alias = await import(URL.pathToFileURL(path.resolve(rootDir, "./alias.mts")).href);
|
|
// alias = alias.default || alias;
|
|
// Object.keys(alias).forEach((key) => {
|
|
// alias[key] = path.resolve(rootDir, alias[key]);
|
|
// });
|
|
const pkgInfo = await import(URL.pathToFileURL(path.resolve(rootDir, "package.json")).href);
|
|
const alias = { [pkgInfo.name]: path.resolve(rootDir, "./src") };
|
|
|
|
const files = fg.sync(["src/**/*.ts"], { cwd: rootDir, ignore: ["**/__tests__/**/*", "**/docs/**/*"] });
|
|
|
|
return build(rootDir, false, {
|
|
rootDir: rootDir,
|
|
entries: files,
|
|
declaration: !isDev,
|
|
replace: {
|
|
__DEV__: String(isDev),
|
|
},
|
|
alias: alias,
|
|
watch: isDev,
|
|
rollup: {
|
|
emitCJS: !isDev,
|
|
output: {
|
|
preserveModules: true,
|
|
preserveModulesRoot: "src",
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|