Public Access
Merge pull request 'Generated clients: exclude vue-ui-kit from Vite pre-bundling, /signup route' (#10) from fix/generated-client-configs into main
Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
commit
0bd1550779
2 files changed
+39
-2
No files matched your search
Vendored
+1
-1
Submodule assets/testdata/template updated: 4143dea0b3...40f5025169.
+38
-1
@@ -128,6 +128,25 @@ func patchNuxtConfig(projectDir, serviceName string) error {
|
|||||||
css: ['~/assets/css/main.css'],
|
css: ['~/assets/css/main.css'],
|
||||||
vite: {
|
vite: {
|
||||||
plugins: [tailwindcss()],
|
plugins: [tailwindcss()],
|
||||||
|
// vue-ui-kit ships raw .vue/.ts source. Left to Vite's dependency
|
||||||
|
// pre-bundler, its index.ts gets bundled with reka-ui inlined while its
|
||||||
|
// .vue files import reka-ui from source - two module instances, so
|
||||||
|
// reka-ui's provide/inject contexts (Dialog, Tabs, Select...) can't find
|
||||||
|
// each other. Excluding it keeps every import on the one reka-ui.
|
||||||
|
optimizeDeps: {
|
||||||
|
exclude: ['@fernandojvideira/vue-ui-kit'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hooks: {
|
||||||
|
// /login and /signup are the two tabs of one auth card, served by the
|
||||||
|
// same page file. A second route record (not an alias - the router
|
||||||
|
// would treat switching between a route and its alias as a duplicate
|
||||||
|
// navigation and drop it) lets the tab change the URL while NuxtPage
|
||||||
|
// keeps the same component instance thanks to the page's fixed key.
|
||||||
|
'pages:extend'(pages) {
|
||||||
|
const login = pages.find((page) => page.path === '/login')
|
||||||
|
if (login) pages.push({ ...login, name: 'signup', path: '/signup' })
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
app: {
|
app: {
|
||||||
@@ -299,13 +318,31 @@ func patchViteConfigForTailwind(projectDir string) error {
|
|||||||
)
|
)
|
||||||
newContent = strings.Replace(newContent, "vueDevTools(),", "vueDevTools(),\n tailwindcss(),", 1)
|
newContent = strings.Replace(newContent, "vueDevTools(),", "vueDevTools(),\n tailwindcss(),", 1)
|
||||||
|
|
||||||
if newContent == string(content) {
|
// create-vue's config ends with the resolve.alias block; hang the
|
||||||
|
// optimizeDeps exclusion off its closing brace.
|
||||||
|
newContent = strings.Replace(newContent,
|
||||||
|
" '@': fileURLToPath(new URL('./src', import.meta.url)),\n },\n },\n})",
|
||||||
|
" '@': fileURLToPath(new URL('./src', import.meta.url)),\n },\n },\n"+viteOptimizeDepsExclude+"})",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
|
||||||
|
if newContent == string(content) || !strings.Contains(newContent, "optimizeDeps") {
|
||||||
return fmt.Errorf("could not find expected anchors in vite.config.ts")
|
return fmt.Errorf("could not find expected anchors in vite.config.ts")
|
||||||
}
|
}
|
||||||
|
|
||||||
return os.WriteFile(configPath, []byte(newContent), 0644)
|
return os.WriteFile(configPath, []byte(newContent), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vue-ui-kit ships raw .vue/.ts source. Left to Vite's dependency pre-bundler,
|
||||||
|
// its index.ts gets bundled with reka-ui inlined while its .vue files import
|
||||||
|
// reka-ui from source - two module instances, so reka-ui's provide/inject
|
||||||
|
// contexts (Dialog, Tabs, Select...) can't find each other. Excluding it keeps
|
||||||
|
// every import on the one reka-ui.
|
||||||
|
const viteOptimizeDepsExclude = ` optimizeDeps: {
|
||||||
|
exclude: ['@fernandojvideira/vue-ui-kit'],
|
||||||
|
},
|
||||||
|
`
|
||||||
|
|
||||||
func patchTsconfigAlias(projectDir string) error {
|
func patchTsconfigAlias(projectDir string) error {
|
||||||
configPath := filepath.Join(projectDir, "tsconfig.json")
|
configPath := filepath.Join(projectDir, "tsconfig.json")
|
||||||
content, err := os.ReadFile(configPath)
|
content, err := os.ReadFile(configPath)
|
||||||
|
|||||||
Reference in new issue
Block a user