-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
61 lines (58 loc) · 2.2 KB
/
Copy pathvite.config.ts
File metadata and controls
61 lines (58 loc) · 2.2 KB
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
import { createRequire } from 'node:module';
import path from 'node:path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import { version } from './package.json' with { type: 'json' };
// `bundleTypes` runs `@microsoft/api-extractor`, and unplugin-dts points it at
// the resolved `typescript` package so that its `lib/` supplies the
// `lib.*.d.ts` files. That breaks here: our `typescript` dependency is the
// `@typescript/typescript6` shim, whose `lib/` merely re-exports the real
// compiler and ships no `lib.dom.d.ts` — leaving API Extractor unable to
// resolve DOM globals ("Unable to follow symbol for HTMLElement"). Point it at
// the package the shim delegates to, which has the actual libs.
const require = createRequire(import.meta.url);
const typescriptCompilerFolder = path.dirname(
require.resolve('@typescript/old/package.json', {
paths: [require.resolve('typescript/package.json')],
}),
);
const banner = `/*!
* Marking Menu Javascript Library v${version}
* https://github.com/QuentinRoy/Marking-Menu
*
* Released under the MIT license.
* https://raw.githubusercontent.com/QuentinRoy/Marking-Menu/main/LICENSE
*
* Marking Menus may be patented independently from this software.
*
* Date: ${new Date().toUTCString()}
*/
`;
export default defineConfig({
plugins: [
dts({
tsconfigPath: 'tsconfig.app.json',
// The declaration rollup starts from package.json's `types`, so that
// path must not collide with the per-file declaration of a source
// module other than the entry: unplugin-dts leaves the existing file in
// place rather than writing the entry re-export there, and API
// Extractor then rolls up the wrong module, silently dropping whatever
// `src/index.ts` adds on top of it. Hence the bundle is named after its
// entry module, `index`, and not after the library.
bundleTypes: { invokeOptions: { typescriptCompilerFolder } },
}),
],
build: {
cssMinify: 'lightningcss',
lib: {
entry: path.resolve(import.meta.dirname, 'src/index.ts'),
fileName: 'index',
formats: ['es'],
},
minify: false,
rolldownOptions: {
output: { banner },
},
sourcemap: true,
},
});