1
1
/// <reference types="vitest" />
2
2
3
3
import { qwikVite } from '@builder.io/qwik/optimizer' ;
4
- import tsconfigPaths from 'vite-tsconfig-paths' ;
5
- import { defineConfig } from 'vite' ;
6
- import dts from 'vite-plugin-dts' ;
7
4
import { dirname , join } from 'path' ;
8
5
import { qwikNxVite } from 'qwik-nx/plugins' ;
9
6
import { fileURLToPath } from 'url' ;
7
+ import { defineConfig } from 'vite' ;
8
+ import dts from 'vite-plugin-dts' ;
9
+ import { viteStaticCopy } from 'vite-plugin-static-copy' ;
10
+ import tsconfigPaths from 'vite-tsconfig-paths' ;
10
11
11
12
export default defineConfig ( {
12
13
plugins : [
@@ -15,7 +16,7 @@ export default defineConfig({
15
16
tsconfigPaths ( { root : '../../' } ) ,
16
17
dts ( {
17
18
tsconfigPath : join ( dirname ( fileURLToPath ( import . meta. url ) ) , 'tsconfig.lib.json' ) ,
18
-
19
+ entryRoot : 'src' ,
19
20
afterDiagnostic ( ds ) {
20
21
// ensure DTS errors are still visible - otherwise get swallowed and silent
21
22
console . log ( ( ds ?? [ ] ) . map ( ( d ) => d . messageText ) ) ;
@@ -29,6 +30,9 @@ export default defineConfig({
29
30
return ;
30
31
} ,
31
32
} ) ,
33
+ viteStaticCopy ( {
34
+ targets : [ { src : './README.md' , dest : './' } ] ,
35
+ } ) ,
32
36
] ,
33
37
server : {
34
38
fs : {
@@ -45,7 +49,8 @@ export default defineConfig({
45
49
entry : './src/index.ts' ,
46
50
// Could also be a dictionary or array of multiple entry points.
47
51
name : 'headless' ,
48
- fileName : ( format ) => `index.qwik.${ format === 'es' ? 'mjs' : 'cjs' } ` ,
52
+ fileName : ( format , entryName ) =>
53
+ `${ entryName } .qwik.${ format === 'es' ? 'mjs' : 'cjs' } ` ,
49
54
// fileName: 'index',
50
55
// Change this to the formats you want to support.
51
56
// Don't forgot to update your package.json as well.
@@ -54,6 +59,10 @@ export default defineConfig({
54
59
rollupOptions : {
55
60
// External packages that should not be bundled into your library.
56
61
external : [ '@floating-ui/dom' , 'country-list-json' , 'libphonenumber-js' ] ,
62
+ output : {
63
+ preserveModules : true ,
64
+ preserveModulesRoot : 'packages/kit-headless/src' ,
65
+ } ,
57
66
} ,
58
67
} ,
59
68
test : {
0 commit comments