-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathbuild.config.ts
47 lines (46 loc) · 1.22 KB
/
build.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
entries: [
'src/index',
'src/nuxt',
'src/dirs',
],
clean: false,
declaration: true,
externals: [
'vite',
'@nuxt/kit',
'@nuxt/schema',
],
rollup: {
emitCJS: true,
inlineDependencies: true,
dts: {
respectExternal: true,
},
},
hooks: {
'build:done': async () => {
console.log('\nChecking client directory...')
const [
{ createRequire },
lstat,
esmDirClient,
] = await Promise.all([
import('node:module').then(m => m.default || m),
import ('node:fs/promises').then(m => m.lstat),
import('./dist/dirs.mjs').then(m => m.DIR_CLIENT),
])
let stats = await lstat(esmDirClient)
if (!stats.isDirectory()) {
throw new Error('ESM: Client directory does not exist, review src/dirs.ts module!')
}
const cjsDirClient = createRequire(import.meta.url)('./dist/dirs.cjs').DIR_CLIENT
stats = await lstat(cjsDirClient)
if (!stats.isDirectory()) {
throw new Error('CJS: Client directory does not exist, review src/dirs.ts module!')
}
console.log('Client directory ok!')
},
},
})