Public Access
Generated clients: exclude vue-ui-kit from Vite pre-bundling, /signup route #10
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'],
|
||||
vite: {
|
||||
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: {
|
||||
@@ -299,13 +318,31 @@ func patchViteConfigForTailwind(projectDir string) error {
|
||||
)
|
||||
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 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 {
|
||||
configPath := filepath.Join(projectDir, "tsconfig.json")
|
||||
content, err := os.ReadFile(configPath)
|
||||
|
||||
Reference in new issue
Block a user