feat(front) : modular nuxt config with app/ shell dirs and modules/* layer auto-detection

This commit is contained in:
Matthieu
2026-06-19 15:24:57 +02:00
parent 1aa43a5356
commit b00e92bdd3
7 changed files with 45 additions and 12 deletions
View File
+45 -12
View File
@@ -1,14 +1,32 @@
import { existsSync, readdirSync } from 'node:fs'
import { resolve } from 'node:path'
const modulesDir = resolve(__dirname, 'modules')
const moduleDirs = existsSync(modulesDir)
? readdirSync(modulesDir, { withFileTypes: true })
.filter((d) => d.isDirectory())
.map((d) => d.name)
: []
const moduleLayers = moduleDirs.map((name) => `./modules/${name}`)
const moduleComposableDirs = moduleDirs
.map((name) => `modules/${name}/composables`)
.filter((path) => existsSync(resolve(__dirname, path)))
const moduleStoreDirs = moduleDirs
.map((name) => `modules/${name}/stores`)
.filter((path) => existsSync(resolve(__dirname, path)))
export default defineNuxtConfig({
compatibilityDate: '2025-07-15',
devtools: {enabled: false},
devtools: { enabled: false },
ssr: false,
srcDir: '.',
css: ['~/assets/css/app.css', '~/assets/css/dark.css'],
app: {
baseURL: process.env.NODE_ENV === 'production'
? (process.env.NUXT_PUBLIC_APP_BASE || '/')
: '/'
: '/',
},
extends: ['@malio/layer-ui'],
extends: ['@malio/layer-ui', ...moduleLayers],
modules: [
'@nuxtjs/tailwindcss',
'@pinia/nuxt',
@@ -16,16 +34,35 @@ export default defineNuxtConfig({
'@nuxtjs/i18n',
'@nuxt/icon',
],
dir: {
layouts: 'app/layouts',
middleware: 'app/middleware',
},
imports: {
dirs: [
'shared/composables',
'shared/stores',
'shared/utils',
'composables',
'stores',
'utils',
...moduleComposableDirs,
...moduleStoreDirs,
],
},
pinia: {
storesDirs: ['shared/stores/**', 'stores/**', 'modules/*/stores/**'],
},
runtimeConfig: {
public: {
apiBase: process.env.NUXT_PUBLIC_API_BASE
}
apiBase: process.env.NUXT_PUBLIC_API_BASE,
},
},
devServer: {
port: 3002,
},
components: [
{path: '~/components', pathPrefix: false},
{ path: '~/components', pathPrefix: false },
],
vite: {
server: {
@@ -56,10 +93,6 @@ export default defineNuxtConfig({
{code: 'fr', file: 'fr.json', name: 'Français'}
],
},
typescript: {
strict: true
},
build: {
transpile: ['@vuepic/vue-datepicker']
}
typescript: { strict: true },
build: { transpile: ['@vuepic/vue-datepicker'] },
})