@@ -11,32 +11,10 @@ import path from 'path';
1111// common config settings
1212const input = [ 'src/index.ts' ] ;
1313const sourceMap = false ;
14-
15- // Ensure styles are copied to the correct location
16- const ensureStyles = ( ) => {
17- return {
18- name : 'ensure-styles' ,
19- writeBundle ( ) {
20- // Copy the primitive styles to the dist directory
21- const primitivesStylesPath = path . resolve ( 'src/components/primitives/styles.css' ) ;
22- const destDir = path . resolve ( 'dist/components/primitives' ) ;
23-
24- // Ensure the directory exists
25- fs . ensureDirSync ( destDir ) ;
26-
27- // Copy the CSS file
28- fs . copyFileSync ( primitivesStylesPath , path . join ( destDir , 'styles.css' ) ) ;
29-
30- console . log ( 'Primitive styles copied successfully' ) ;
31- }
32- } ;
33- } ;
34-
14+ const tsconfig = 'tsconfig.dist.json' ;
3515const esmOutputDir = 'dist/esm' ;
3616
37- /**
38- * @type {import('rollup').OutputOptions }
39- */
17+ // Common output options
4018const cjsOutput = {
4119 dir : 'dist' ,
4220 entryFileNames : '[name].cjs' ,
@@ -47,59 +25,48 @@ const cjsOutput = {
4725 exports : 'named'
4826} ;
4927
50- // Vue plugin configuration - customized for full SFC compilation
51- const vuePlugin = vue ( {
52- // Enable pre-processing of styles
53- preprocessStyles : true ,
54- // Use custom compiler options
55- template : {
56- isProduction : true ,
57- compilerOptions : {
58- whitespace : 'condense' ,
59- // Don't treat kebab-case components as custom elements
60- isCustomElement : tag => / ^ a m p l i f y - / . test ( tag )
28+ // Common plugins
29+ const commonPlugins = [
30+ externals ( { include : [ / n o d e _ m o d u l e s / , / ^ @ a w s - a m p l i f y / ] } ) ,
31+ nodeResolve ( { extensions : [ '.js' , '.ts' , '.vue' , '.css' ] } ) ,
32+ commonjs ( { include : / n o d e _ m o d u l e s / } ) ,
33+ postcss ( { extract : false , inject : false } ) ,
34+ vue ( {
35+ preprocessStyles : true ,
36+ template : {
37+ isProduction : true ,
38+ compilerOptions : {
39+ whitespace : 'condense' ,
40+ isCustomElement : tag => / ^ a m p l i f y - / . test ( tag )
41+ }
6142 }
43+ } )
44+ ] ;
45+
46+ // Ensure styles are copied
47+ const ensureStyles = ( ) => ( {
48+ name : 'ensure-styles' ,
49+ writeBundle ( ) {
50+ fs . ensureDirSync ( 'dist/components/primitives' ) ;
51+ fs . copyFileSync (
52+ 'src/components/primitives/styles.css' ,
53+ 'dist/components/primitives/styles.css'
54+ ) ;
6255 }
6356} ) ;
6457
65- // External dependencies
66- const externalDeps = [
67- 'vue' ,
68- '@vueuse/core' ,
69- '@xstate/vue' ,
70- 'xstate' ,
71- / ^ @ a w s - a m p l i f y /
72- ] ;
73-
7458const config = defineConfig ( [
7559 // CJS config
7660 {
7761 input,
7862 output : cjsOutput ,
79- external : externalDeps ,
8063 plugins : [
81- externals ( { include : [ / n o d e _ m o d u l e s / , / ^ @ a w s - a m p l i f y / ] } ) ,
82- nodeResolve ( {
83- extensions : [ '.js' , '.ts' , '.vue' , '.css' ]
84- } ) ,
85- commonjs ( {
86- include : / n o d e _ m o d u l e s /
87- } ) ,
88- postcss ( {
89- extract : false ,
90- inject : false
91- } ) ,
92- vuePlugin ,
64+ ...commonPlugins ,
9365 typescript ( {
9466 check : false ,
9567 useTsconfigDeclarationDir : true ,
9668 tsconfigOverride : {
97- compilerOptions : {
98- sourceMap,
99- declaration : true ,
100- declarationDir : 'dist' ,
101- rootDir : 'src' ,
102- } ,
69+ compilerOptions : { sourceMap, declaration : true , declarationDir : 'dist' , rootDir : 'src' } ,
10370 include : [ 'src/**/*' ] ,
10471 exclude : [ 'node_modules' , '**/__tests__/**' , '**/*.test.*' ]
10572 }
@@ -117,36 +84,18 @@ const config = defineConfig([
11784 preserveModules : true ,
11885 preserveModulesRoot : 'src'
11986 } ,
120- external : externalDeps ,
12187 plugins : [
122- externals ( { include : [ / n o d e _ m o d u l e s / , / ^ @ a w s - a m p l i f y / ] } ) ,
123- nodeResolve ( {
124- extensions : [ '.js' , '.ts' , '.vue' , '.css' ]
125- } ) ,
126- commonjs ( {
127- include : / n o d e _ m o d u l e s /
128- } ) ,
129- postcss ( {
130- extract : false ,
131- inject : false
132- } ) ,
133- vuePlugin ,
88+ ...commonPlugins ,
13489 typescript ( {
13590 check : false ,
13691 tsconfigOverride : {
137- compilerOptions : {
138- sourceMap,
139- declaration : false ,
140- rootDir : 'src' ,
141- outDir : esmOutputDir ,
142- } ,
92+ compilerOptions : { sourceMap, declaration : false , rootDir : 'src' , outDir : esmOutputDir } ,
14393 include : [ 'src/**/*' ] ,
14494 exclude : [ 'node_modules' , '**/__tests__/**' , '**/*.test.*' ]
14595 }
146- } ) ,
96+ } )
14797 ] ,
14898 } ,
14999] ) ;
150100
151101export default config ;
152-
0 commit comments