nuxt.config.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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-19 09:24:19
  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: [resolve('./stores'), '~/stores'],
  40. },
  41. css: ['@unocss/reset/tailwind.css', '~/assets/scss/common.scss'],
  42. vite: {
  43. css: {
  44. preprocessorOptions: {
  45. scss: {
  46. additionalData: `@use "~/assets/scss/vars.scss";`,
  47. },
  48. },
  49. },
  50. },
  51. nitro: {
  52. devProxy: {
  53. '/yyds': {
  54. target: 'https://wisdomcity.eu.org:30032/yyds',
  55. changeOrigin: true,
  56. prependPath: true,
  57. secure: false,
  58. },
  59. },
  60. },
  61. build: {},
  62. runtimeConfig: {
  63. public: {
  64. apiBase: process.env.NUXT_PUBLIC_API_BASE,
  65. },
  66. },
  67. app: {
  68. head: {
  69. viewport: 'width=device-width,initial-scale=1',
  70. link: [
  71. { rel: 'icon', href: '/logo.png', sizes: 'any' },
  72. { rel: 'icon', href: '/logo.png' },
  73. { rel: 'apple-touch-icon', href: '/logo.png' },
  74. ],
  75. meta: [
  76. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  77. { name: 'description', content: appDescription },
  78. { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
  79. ],
  80. },
  81. },
  82. features: {
  83. inlineStyles: false,
  84. },
  85. components: true,
  86. sourcemap: {
  87. client: true,
  88. server: false,
  89. },
  90. })