schon/storefront/nuxt.config.ts
Alexandr SaVBaD Waltz 2ea18eb8a6 feat(storefront): refactor i18n and cart/wishlist handling for improved user experience
Refactored i18n configuration, replacing `DEFAULT_LOCALE` with `DEFAULT_LOCALE_FALLBACK` and enhancing environment-based locale validation. Improved cookie persistence for cart and wishlist, ensuring fallback handling for unauthenticated users.

Enhancements:
- Added `createProjectKey` utility for consistent project key generation.
- Reworked cart and wishlist composables (`useOrderOverwrite`, `useWishlistOverwrite`) to decouple product identifier and handle cookies robustly.
- Centralized `DEFAULT_LOCALE` logic for better maintainability.
- Refined `useOrderSync` and `useWishlistSync` for clean synchronization across auth states.
- Updated SCSS in hero and header styles for alignment corrections.

Breaking Changes: `DEFAULT_LOCALE` constant removed; replaced with runtime config and fallback logic. Consumers must adapt to `DEFAULT_LOCALE_FALLBACK` and `$appHelpers.DEFAULT_LOCALE`.
2026-02-28 22:38:45 +03:00

117 lines
2.7 KiB
TypeScript

import { resolve } from 'node:path';
import { fileURLToPath, URL } from 'node:url';
import { createProjectKey } from './app/utils/transliterator';
import { createI18nConfig } from './i18n/i18.config';
export default defineNuxtConfig({
compatibilityDate: '2025-07-15',
ssr: true,
devtools: {
enabled: true,
},
typescript: {
strict: true,
},
modules: [
'@nuxtjs/i18n',
'@nuxt/icon',
'@pinia/nuxt',
'@nuxtjs/apollo',
'@vueuse/nuxt',
'@element-plus/nuxt',
'nuxt-marquee',
'@nuxt/hints',
'@nuxt/image',
],
i18n: createI18nConfig(process.env.SCHON_LANGUAGE_CODE),
apollo: {
autoImports: true,
clients: {
default: {
httpEndpoint: `https://api.${process.env.SCHON_BASE_DOMAIN}/graphql/`,
connectToDevTools: true,
authType: 'Bearer',
authHeader: 'X-SCHON-AUTH',
tokenStorage: 'cookie',
tokenName: `${createProjectKey(process.env.SCHON_PROJECT_NAME)}-access`,
},
},
},
runtimeConfig: {
public: {
schonProjectName: process.env.SCHON_PROJECT_NAME,
schonBaseDomain: process.env.SCHON_BASE_DOMAIN,
schonLanguageCode: process.env.SCHON_LANGUAGE_CODE,
},
},
app: {
head: {
charset: 'utf-8',
viewport: 'width=device-width, initial-scale=1',
title: process.env.SCHON_PROJECT_NAME,
titleTemplate: `${process.env.SCHON_PROJECT_NAME} | %s`,
link: [
{
rel: 'icon',
type: 'image/x-icon',
href: `https://${process.env.SCHON_BASE_DOMAIN}/favicon.ico`,
},
],
},
pageTransition: {
name: 'opacity',
mode: 'out-in',
},
},
css: [
'./app/assets/styles/main.scss',
'./app/assets/styles/global/fonts.scss',
'swiper/css',
'swiper/css/pagination',
'swiper/css/navigation',
'swiper/css/effect-fade',
'swiper/css/scrollbar',
],
alias: {
'@graphql': fileURLToPath(new URL('./app/graphql', import.meta.url)),
'@appConstants': fileURLToPath(new URL('./app/constants', import.meta.url)),
'@composables': fileURLToPath(new URL('./app/composables', import.meta.url)),
'@types': fileURLToPath(new URL('./types', import.meta.url)),
'@utils': fileURLToPath(new URL('./app/utils', import.meta.url)),
},
vite: {
envDir: '../',
envPrefix: 'SCHON_',
css: {
preprocessorOptions: {
scss: {
additionalData: `
@use "@/assets/styles/global/variables.scss" as *;
@use "@/assets/styles/global/mixins.scss" as *;
`,
},
},
},
},
image: {
domains: [
`https://api.${process.env.SCHON_BASE_DOMAIN}`,
],
},
hooks: {
'pages:extend'(pages) {
pages.push(
{
name: 'activate-user',
path: '/activate-user',
file: resolve(__dirname, 'app/pages/index.vue'),
},
{
name: 'payment',
path: '/payment',
file: resolve(__dirname, 'app/pages/index.vue'),
},
);
},
},
});