123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- /** @format */
- import process from 'node:process'
- import { sitemapConfig } from './utils/sitemap.config'
- const isDev = process.env.NODE_ENV === 'development'
- export default defineNuxtConfig({
- ssr: true,
- app: {
- pageTransition: { name: 'page', mode: 'out-in', onBeforeEnter: () => { window.scrollTo(0, 0) } },
- // layoutTransition: { name: 'layout', mode: 'out-in', onBeforeEnter() { window.scrollTo(0, 0) } },
- head: {
- htmlAttrs: {
- lang: 'en',
- },
- },
- },
- modules: [
- '@unocss/nuxt',
- '@vueuse/nuxt',
- '@nuxt/image',
- '@nuxtjs/i18n',
- '@nuxtjs/html-validator',
- '@element-plus/nuxt',
- '@pinia/nuxt',
- '@pinia-plugin-persistedstate/nuxt',
- 'nuxt-svgo',
- '@nuxtjs/sitemap',
- ],
- css: [
- 'element-plus/dist/index.css',
- 'element-plus/theme-chalk/display.css',
- '@/assets/style/reset.css',
- '@/assets/style/public.css',
- '@/assets/style/variables.css',
- '@/assets/style/common.less',
- ],
- experimental: {
- inlineSSRStyles: false,
- viewTransition: true,
- renderJsonPayloads: true,
- },
- routeRules: {
- '/**': isDev
- ? {}
- : {
- cache: { swr: true, maxAge: 120, staleMaxAge: 60, headersOnly: true },
- },
- },
- runtimeConfig: {
- public: {
- apiBase: process.env.MY_ENV_BASE,
- apiBaseUrl: process.env.MY_ENV_DEV_URL,
- apiBaseSiteUrl: 'http://47.99.151.233:9301',
- scrollToTop: true,
- },
- },
- devtools: {
- enabled: true,
- },
- // image: {
- // provider: 'proxy',
- // providers: {
- // proxy: {
- // provider: 'ipx',
- // options: {
- // baseURL: `${apiBaseUrl}/ipx`,
- // },
- // },
- // },
- // },
- nitro: {
- routeRules: {
- '/**': { isr: false },
- },
- devProxy: {
- '/jeecgboot': {
- target: process.env.MY_ENV_DEV_URL,
- changeOrigin: true,
- },
- },
- },
- i18n: {
- detectBrowserLanguage: {
- useCookie: true,
- fallbackLocale: 'en',
- },
- strategy: 'no_prefix',
- locales: [
- {
- code: 'en',
- name: 'English',
- file: 'en.json',
- },
- {
- code: 'zh-CN',
- name: '简体中文',
- file: 'zh-CN.json',
- },
- ],
- lazy: true,
- langDir: 'internationalization',
- defaultLocale: 'en',
- },
- htmlValidator: {
- usePrettier: false,
- logLevel: 'verbose',
- failOnError: false,
- /** A list of routes to ignore (that is, not check validity for). */
- ignore: [/\.(xml|rss|json)$/],
- options: {
- extends: [
- 'html-validate:document',
- 'html-validate:recommended',
- 'html-validate:standard',
- ],
- rules: {
- 'svg-focusable': 'off',
- 'no-unknown-elements': 'error',
- // Conflicts or not needed as we use prettier formatting
- 'void-style': 'off',
- 'no-trailing-whitespace': 'off',
- // Conflict with Nuxt defaults
- 'require-sri': 'off',
- 'attribute-boolean-style': 'off',
- 'doctype-style': 'off',
- // Unreasonable rule
- 'no-inline-style': 'off',
- },
- },
- },
- sitemap: {
- urls: async () => {
- // 只生成静态路由
- const staticRoutes = sitemapConfig.staticRoutes.map(route => ({
- ...route,
- loc: `${sitemapConfig.hostname}${route.loc}`,
- lastmod: new Date().toISOString(),
- }))
- // 生成动态路由
- const dynamicRoutes = await sitemapConfig.generateDynamicRoutes()
- const dynamics = dynamicRoutes.map(route => ({
- ...route,
- loc: route.loc,
- lastmod: new Date().toISOString(),
- }))
- // 合并路由
- const routes = [...staticRoutes, ...dynamics]
- return routes
- },
- defaults: {
- changefreq: 'daily',
- priority: 0.5,
- lastmod: new Date().toISOString(),
- },
- exclude: [
- '/404',
- ],
- // exclude all app sources
- excludeAppSources: true,
- debug: true,
- },
- })
|