11/// <reference types="vitest" />
22
33import { 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' ;
74import { dirname , join } from 'path' ;
85import { qwikNxVite } from 'qwik-nx/plugins' ;
96import { 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' ;
1011
1112export default defineConfig ( {
1213 plugins : [
@@ -15,7 +16,7 @@ export default defineConfig({
1516 tsconfigPaths ( { root : '../../' } ) ,
1617 dts ( {
1718 tsconfigPath : join ( dirname ( fileURLToPath ( import . meta. url ) ) , 'tsconfig.lib.json' ) ,
18-
19+ entryRoot : 'src' ,
1920 afterDiagnostic ( ds ) {
2021 // ensure DTS errors are still visible - otherwise get swallowed and silent
2122 console . log ( ( ds ?? [ ] ) . map ( ( d ) => d . messageText ) ) ;
@@ -29,6 +30,9 @@ export default defineConfig({
2930 return ;
3031 } ,
3132 } ) ,
33+ viteStaticCopy ( {
34+ targets : [ { src : './README.md' , dest : './' } ] ,
35+ } ) ,
3236 ] ,
3337 server : {
3438 fs : {
@@ -45,7 +49,8 @@ export default defineConfig({
4549 entry : './src/index.ts' ,
4650 // Could also be a dictionary or array of multiple entry points.
4751 name : 'headless' ,
48- fileName : ( format ) => `index.qwik.${ format === 'es' ? 'mjs' : 'cjs' } ` ,
52+ fileName : ( format , entryName ) =>
53+ `${ entryName } .qwik.${ format === 'es' ? 'mjs' : 'cjs' } ` ,
4954 // fileName: 'index',
5055 // Change this to the formats you want to support.
5156 // Don't forgot to update your package.json as well.
@@ -54,6 +59,10 @@ export default defineConfig({
5459 rollupOptions : {
5560 // External packages that should not be bundled into your library.
5661 external : [ '@floating-ui/dom' , 'country-list-json' , 'libphonenumber-js' ] ,
62+ output : {
63+ preserveModules : true ,
64+ preserveModulesRoot : 'packages/kit-headless/src' ,
65+ } ,
5766 } ,
5867 } ,
5968 test : {
0 commit comments