1
1
import { alias } from '@stacksjs/alias'
2
- import { path as p } from '@stacksjs/path'
2
+ import { config as c } from '@stacksjs/config'
3
+ import { libraryEntryPath , libsPath , projectPath , publicPath , resourcesPath } from '@stacksjs/path'
3
4
import { server } from '@stacksjs/server'
5
+ import type { ViteConfig } from '@stacksjs/types'
6
+ import { autoImports , components , cssEngine , devtools , inspect , uiEngine } from '@stacksjs/vite-plugin'
4
7
import { defineConfig } from 'vite'
5
8
import type { ViteBuildOptions } from '.'
6
9
7
- // import { autoImports, components, cssEngine, inspect, uiEngine } from '.'
8
-
9
- // const isWebComponent = true
10
-
11
- export const webComponentsConfig = {
12
- root : p . frameworkPath ( 'libs/components/web' ) ,
13
- envDir : p . projectPath ( ) ,
10
+ const config = {
11
+ root : libsPath ( 'components/web' ) ,
12
+ envDir : projectPath ( ) ,
14
13
envPrefix : 'FRONTEND_' ,
14
+ publicDir : publicPath ( ) ,
15
+ base : '/libs/' ,
16
+
17
+ assetsInclude : [ publicPath ( '**/*' ) , resourcesPath ( 'assets/*' ) , resourcesPath ( 'assets/**/*' ) ] ,
15
18
16
19
server : server ( {
17
20
type : 'library' ,
18
21
} ) ,
19
22
20
23
resolve : {
24
+ dedupe : [ 'vue' ] ,
21
25
alias,
22
26
} ,
23
27
@@ -26,38 +30,47 @@ export const webComponentsConfig = {
26
30
} ,
27
31
28
32
plugins : [
29
- // inspect(),
30
- // uiEngine(isWebComponent),
31
- // cssEngine(isWebComponent),
32
- // autoImports(),
33
- // components(),
33
+ uiEngine ( true ) ,
34
+ autoImports ( ) ,
35
+ cssEngine ( ) ,
36
+ inspect ( ) ,
37
+ components ( ) ,
38
+ devtools ( ) ,
39
+ // stacks(),
34
40
] ,
35
41
36
42
build : webComponentsBuildOptions ( ) ,
37
- }
43
+ } satisfies ViteConfig
38
44
39
45
export function webComponentsBuildOptions ( ) : ViteBuildOptions {
40
46
return {
41
- outDir : p . frameworkPath ( 'components/web/dist' ) ,
47
+ outDir : libsPath ( 'components/web/dist' ) ,
42
48
emptyOutDir : true ,
43
49
lib : {
44
- entry : p . libraryEntryPath ( 'web-components' ) ,
45
- name : 'web-components' ,
46
- formats : [ 'cjs' , ' es'] ,
50
+ entry : libraryEntryPath ( 'web-components' ) ,
51
+ name : c . library . webComponents ?. name ,
52
+ formats : [ 'es' ] ,
47
53
fileName : ( format : string ) => {
48
- if ( format === 'es' ) return 'index.mjs'
49
-
50
- if ( format === 'cjs' ) return 'index.cjs'
54
+ if ( format === 'es' ) return 'index.js'
51
55
52
56
return 'index.?.js'
53
57
} ,
54
58
} ,
59
+
60
+ // rollupOptions: {
61
+ // external: ['vue', '@stacksjs/path'],
62
+ // input: libraryEntryPath('web-components'),
63
+ // output: {
64
+ // globals: {
65
+ // vue: 'Vue',
66
+ // },
67
+ // },
68
+ // },
55
69
}
56
70
}
57
71
58
72
export default defineConfig ( ( { command } ) => {
59
- if ( command === 'serve' ) return webComponentsConfig
73
+ if ( command === 'serve' ) return config
60
74
61
- // command === 'build'
62
- return webComponentsConfig
75
+ return config
63
76
} )
0 commit comments