generated from dev-protocol/clubs-plugin-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
59 lines (56 loc) · 1.29 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
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'),
}),
],
},
]