nuxt.config.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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-22 10:30:54
  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. alias: {
  21. '@': fileURLToPath(new URL('./app', import.meta.url)),
  22. },
  23. modules: [
  24. '@vueuse/nuxt',
  25. '@unocss/nuxt',
  26. '@pinia/nuxt',
  27. '@element-plus/nuxt',
  28. // '@nuxtjs/color-mode',
  29. // '@nuxtjs/i18n',
  30. ],
  31. experimental: {
  32. // when using generate, payload js assets included in sw precache manifest
  33. // but missing on offline, disabling extraction it until fixed
  34. payloadExtraction: false,
  35. renderJsonPayloads: false,
  36. typedPages: false,
  37. },
  38. imports: {
  39. dirs: [
  40. resolve('./app/stores'),
  41. resolve('./app/composables'),
  42. resolve('./app/components'),
  43. resolve('./app/components/section'),
  44. ],
  45. },
  46. css: ['@unocss/reset/tailwind.css', '~/assets/scss/common.scss'],
  47. vite: {
  48. css: {
  49. preprocessorOptions: {
  50. scss: {
  51. additionalData: `@use "~/assets/scss/vars.scss";`,
  52. },
  53. },
  54. },
  55. },
  56. nitro: {
  57. devProxy: {
  58. '/yyds': {
  59. target: 'https://wisdomcity.eu.org:30032/yyds',
  60. changeOrigin: true,
  61. prependPath: true,
  62. secure: false,
  63. },
  64. },
  65. },
  66. build: {},
  67. runtimeConfig: {
  68. public: {
  69. apiBase: process.env.NUXT_PUBLIC_API_BASE,
  70. },
  71. },
  72. app: {
  73. head: {
  74. viewport: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
  75. link: [
  76. { rel: 'icon', href: '/logo.png', sizes: 'any' },
  77. { rel: 'icon', href: '/logo.png' },
  78. { rel: 'apple-touch-icon', href: '/logo.png' },
  79. {
  80. rel: 'preload',
  81. href: '/fonts/D-DIN-PRO-600-SemiBold.woff2',
  82. as: 'font',
  83. type: 'font/woff2',
  84. crossorigin: 'anonymous',
  85. },
  86. ],
  87. meta: [
  88. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  89. { name: 'description', content: appDescription },
  90. { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
  91. ],
  92. },
  93. },
  94. features: {
  95. inlineStyles: false,
  96. },
  97. components: true,
  98. sourcemap: {
  99. client: true,
  100. server: false,
  101. },
  102. })