nuxt.config.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // https://nuxt.com/docs/api/configuration/nuxt-config
  2. /*
  3. * @Author: wjc
  4. * @Date: 2023-10-25 19:39:32
  5. * @LastEditors: LiZhiWei
  6. * @LastEditTime: 2026-01-09 16:29:20
  7. * @Description:
  8. */
  9. import { loadEnv } from 'vite'
  10. import { createResolver } from '@nuxt/kit'
  11. const { resolve } = createResolver(import.meta.url)
  12. import { fileURLToPath } from 'url'
  13. import { appDescription } from './app/constants/index'
  14. const envName = process.env.npm_lifecycle_script?.match(/--mode\s(.*)/)?.[1] ?? 'development'
  15. const envData = loadEnv(envName, process.cwd()) // 获取.env文件中的配置
  16. Object.assign(process.env, envData) // 将环境配置信息,添加到process.env
  17. export default defineNuxtConfig({
  18. compatibilityDate: '2026-01-09',
  19. routeRules: {
  20. },
  21. alias: {
  22. '@': fileURLToPath(new URL('./app', import.meta.url)),
  23. },
  24. modules: [
  25. '@vueuse/nuxt',
  26. '@unocss/nuxt',
  27. '@pinia/nuxt',
  28. '@element-plus/nuxt',
  29. // '@nuxtjs/color-mode',
  30. // '@nuxtjs/i18n',
  31. ],
  32. experimental: {
  33. // when using generate, payload js assets included in sw precache manifest
  34. // but missing on offline, disabling extraction it until fixed
  35. payloadExtraction: false,
  36. renderJsonPayloads: false,
  37. typedPages: false,
  38. },
  39. imports: {
  40. dirs: [resolve('./stores'), '~/stores'],
  41. },
  42. css: ['@unocss/reset/tailwind.css'],
  43. vite: {
  44. css: {
  45. preprocessorOptions: {
  46. scss: {
  47. additionalData: `@use "~/assets/scss/vars.scss";`,
  48. },
  49. },
  50. },
  51. },
  52. nitro: {
  53. devProxy: {
  54. '/yyds': {
  55. target: 'https://wisdomcity.eu.org:30032/yyds',
  56. changeOrigin: true,
  57. prependPath: true,
  58. secure: false,
  59. },
  60. },
  61. },
  62. build: {},
  63. runtimeConfig: {
  64. public: {
  65. apiBase: process.env.NUXT_PUBLIC_API_BASE,
  66. },
  67. },
  68. app: {
  69. head: {
  70. viewport: 'width=device-width,initial-scale=1',
  71. link: [
  72. { rel: 'icon', href: '/logo.png', sizes: 'any' },
  73. { rel: 'icon', href: '/logo.png' },
  74. { rel: 'apple-touch-icon', href: '/logo.png' },
  75. ],
  76. meta: [
  77. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  78. { name: 'description', content: appDescription },
  79. { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
  80. ],
  81. },
  82. },
  83. features: {
  84. inlineStyles: false,
  85. },
  86. components: true,
  87. sourcemap: {
  88. client: true,
  89. server: false,
  90. },
  91. })