Skip to content

Commit 4343b0e

Browse files
committed
chore: wip
1 parent 2a90151 commit 4343b0e

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
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'
34
import { server } from '@stacksjs/server'
5+
import type { ViteConfig } from '@stacksjs/types'
6+
import { autoImports, components, cssEngine, devtools, inspect, uiEngine } from '@stacksjs/vite-plugin'
47
import { defineConfig } from 'vite'
58
import type { ViteBuildOptions } from '.'
69

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(),
1413
envPrefix: 'FRONTEND_',
14+
publicDir: publicPath(),
15+
base: '/libs/',
16+
17+
assetsInclude: [publicPath('**/*'), resourcesPath('assets/*'), resourcesPath('assets/**/*')],
1518

1619
server: server({
1720
type: 'library',
1821
}),
1922

2023
resolve: {
24+
dedupe: ['vue'],
2125
alias,
2226
},
2327

@@ -26,38 +30,47 @@ export const webComponentsConfig = {
2630
},
2731

2832
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(),
3440
],
3541

3642
build: webComponentsBuildOptions(),
37-
}
43+
} satisfies ViteConfig
3844

3945
export function webComponentsBuildOptions(): ViteBuildOptions {
4046
return {
41-
outDir: p.frameworkPath('components/web/dist'),
47+
outDir: libsPath('components/web/dist'),
4248
emptyOutDir: true,
4349
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'],
4753
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'
5155

5256
return 'index.?.js'
5357
},
5458
},
59+
60+
// rollupOptions: {
61+
// external: ['vue', '@stacksjs/path'],
62+
// input: libraryEntryPath('web-components'),
63+
// output: {
64+
// globals: {
65+
// vue: 'Vue',
66+
// },
67+
// },
68+
// },
5569
}
5670
}
5771

5872
export default defineConfig(({ command }) => {
59-
if (command === 'serve') return webComponentsConfig
73+
if (command === 'serve') return config
6074

61-
// command === 'build'
62-
return webComponentsConfig
75+
return config
6376
})

storage/framework/core/vite-plugin/src/css-engine.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// import { path as p } from '@stacksjs/path'
22
import UnoCSS from 'unocss/vite'
33

4-
export function cssEngine() {
5-
// export function cssEngine(isWebComponent = false) {
6-
// return UnoCSS()
4+
export function cssEngine(isWebComponent = false) {
75
return UnoCSS({
86
configFile: '../../ui/src/unocss.config.ts',
9-
// mode: isWebComponent ? 'shadow-dom' : 'vue-scoped',
7+
mode: isWebComponent ? 'shadow-dom' : 'vue-scoped',
108
// content: {
119
// pipeline: {
1210
// include: /\.(stx|vue|js|ts|mdx?|elm|html)($|\?)/,

storage/framework/libs/components/web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"types": "dist/index.d.ts",
3636
"files": ["README.md", "dist", "src"],
3737
"scripts": {
38-
"build": "vite build -c ../build/web-components.ts",
38+
"dev": "bunx vite -c ../../../core/vite-config/src/web-components.ts",
39+
"build": "bunx vite build -c ../../../core/vite-config/src/web-components.ts",
3940
"prepublishOnly": "bun run build"
4041
},
4142
"devDependencies": {

0 commit comments

Comments
 (0)