@@ -11,32 +11,10 @@ import path from 'path';
11
11
// common config settings
12
12
const input = [ 'src/index.ts' ] ;
13
13
const 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' ;
35
15
const esmOutputDir = 'dist/esm' ;
36
16
37
- /**
38
- * @type {import('rollup').OutputOptions }
39
- */
17
+ // Common output options
40
18
const cjsOutput = {
41
19
dir : 'dist' ,
42
20
entryFileNames : '[name].cjs' ,
@@ -47,59 +25,48 @@ const cjsOutput = {
47
25
exports : 'named'
48
26
} ;
49
27
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
+ }
61
42
}
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
+ ) ;
62
55
}
63
56
} ) ;
64
57
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
-
74
58
const config = defineConfig ( [
75
59
// CJS config
76
60
{
77
61
input,
78
62
output : cjsOutput ,
79
- external : externalDeps ,
80
63
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 ,
93
65
typescript ( {
94
66
check : false ,
95
67
useTsconfigDeclarationDir : true ,
96
68
tsconfigOverride : {
97
- compilerOptions : {
98
- sourceMap,
99
- declaration : true ,
100
- declarationDir : 'dist' ,
101
- rootDir : 'src' ,
102
- } ,
69
+ compilerOptions : { sourceMap, declaration : true , declarationDir : 'dist' , rootDir : 'src' } ,
103
70
include : [ 'src/**/*' ] ,
104
71
exclude : [ 'node_modules' , '**/__tests__/**' , '**/*.test.*' ]
105
72
}
@@ -117,36 +84,18 @@ const config = defineConfig([
117
84
preserveModules : true ,
118
85
preserveModulesRoot : 'src'
119
86
} ,
120
- external : externalDeps ,
121
87
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 ,
134
89
typescript ( {
135
90
check : false ,
136
91
tsconfigOverride : {
137
- compilerOptions : {
138
- sourceMap,
139
- declaration : false ,
140
- rootDir : 'src' ,
141
- outDir : esmOutputDir ,
142
- } ,
92
+ compilerOptions : { sourceMap, declaration : false , rootDir : 'src' , outDir : esmOutputDir } ,
143
93
include : [ 'src/**/*' ] ,
144
94
exclude : [ 'node_modules' , '**/__tests__/**' , '**/*.test.*' ]
145
95
}
146
- } ) ,
96
+ } )
147
97
] ,
148
98
} ,
149
99
] ) ;
150
100
151
101
export default config ;
152
-
0 commit comments