generated from dev-protocol/clubs-plugin-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
88 lines (85 loc) · 1.8 KB
/
rollup.config.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { dirname, relative, resolve } from 'path'
import typescript from '@rollup/plugin-typescript'
import dts from 'rollup-plugin-dts'
import { cwd } from 'process'
const dir = 'dist'
const useSrc = ({ out, ext } = {}) => ({
name: 'local:useSrc',
resolveId(source, importer) {
if (ext.some((e) => source.endsWith(e))) {
const here = cwd()
const from =
typeof out === 'string'
? out
: dirname(typeof out === 'function' ? out(importer) : importer)
const originalImporter = importer.replace(`${here}/dist`, here)
const originalImporterDir = dirname(originalImporter)
const original = resolve(originalImporterDir, source)
const relativePath = relative(from, original)
return {
id: relativePath,
external: true,
}
}
},
})
export default [
{
input: 'src/index.ts',
output: [
{
dir,
format: 'es',
},
],
plugins: [
typescript(),
useSrc({
ext: ['.astro', '.svelte', '.vue', '.scss', '.css'],
dir,
out: (path) => path.replace('src', 'dist'),
}),
],
},
{
input: 'dist/src/index.d.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [
dts(),
useSrc({
ext: ['.astro', '.svelte', '.vue', '.scss', '.css', '.png', '.jpg'],
dir,
out: (path) => path.replace('dist/src', 'dist'),
}),
],
},
{
input: 'src/components/index.ts',
output: [
{
file: 'dist/components.js',
format: 'es',
},
],
plugins: [
typescript(),
useSrc({
ext: ['.astro', '.vue'],
dir,
out: (path) => path.replace('src/components', 'dist'),
}),
],
},
{
input: 'dist/src/components/index.d.ts',
output: [{ file: 'components.d.ts', format: 'es' }],
plugins: [
dts(),
useSrc({
ext: ['.astro', '.vue'],
dir,
out: (path) => path.replace('dist/src/components', ''),
}),
],
},
]