nuxt.config.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import fs from 'fs'
  2. import vuetify from 'vite-plugin-vuetify'
  3. import type { NuxtI18nOptions } from '@nuxtjs/i18n'
  4. let https = {}
  5. const transpile = ['vuetify', 'pinia', 'pinia-orm', 'date-fns']
  6. if (!process.env.NUXT_ENV) {
  7. throw new Error('Missing environment file - Run yarn install')
  8. }
  9. if (process.env.NUXT_ENV === 'dev') {
  10. https = {
  11. key: fs.readFileSync('env/local.logiciels.opentalent.fr.key'),
  12. cert: fs.readFileSync('env/local.logiciels.opentalent.fr.crt'),
  13. }
  14. } else {
  15. transpile.push('lodash')
  16. }
  17. /**
  18. * Nuxt configuration
  19. *
  20. * @see https://nuxt.com/docs/api/configuration/nuxt-config
  21. */
  22. export default defineNuxtConfig({
  23. ssr: true,
  24. experimental: {
  25. // Fix the 'Cannot stringify non POJO' bug
  26. // @see https://github.com/nuxt/nuxt/issues/20787
  27. renderJsonPayloads: false,
  28. },
  29. routeRules: {
  30. // all routes will be generated at build time and cached permanently
  31. '/**': { prerender: true },
  32. // these pages will be background revalidated (ISR) at most every 60 seconds
  33. '/actualites': { isr: 60 },
  34. '/actualites/**': { isr: 60 },
  35. '/nous-rejoindre': { isr: 60 },
  36. '/nous-rejoindre/**': { isr: 60 },
  37. },
  38. title: 'Opentalent',
  39. runtimeConfig: {
  40. // Private config that is only available on the server
  41. env: '',
  42. siteUrl: '',
  43. apiBaseUrl: '',
  44. ap2iBaseUrl: '',
  45. agendaBaseUrl: '',
  46. fileStorageBaseUrl: '',
  47. hCaptchaSiteKey: '35360874-ebb1-4748-86e3-9b156d5bfc53',
  48. // Config within public will be also exposed to the client
  49. public: {
  50. env: '',
  51. siteUrl: '',
  52. apiBaseUrl: '',
  53. ap2iBaseUrl: '',
  54. agendaBaseUrl: '',
  55. fileStorageBaseUrl: '',
  56. hCaptchaSiteKey: '35360874-ebb1-4748-86e3-9b156d5bfc53',
  57. },
  58. },
  59. css: ['~/assets/style/main.scss', '~/assets/style/theme.scss'],
  60. hooks: {
  61. 'builder:watch': console.log,
  62. },
  63. app: {
  64. head: {
  65. title: 'Opentalent',
  66. meta: [
  67. { charset: 'utf-8' },
  68. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  69. ],
  70. link: [
  71. { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
  72. {
  73. rel: 'stylesheet',
  74. href: 'https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;700&display=swap',
  75. },
  76. ],
  77. },
  78. },
  79. typescript: {
  80. strict: true,
  81. },
  82. modules: [
  83. // eslint-disable-next-line require-await
  84. async (_, nuxt) => {
  85. nuxt.hooks.hook('vite:extendConfig', (config) =>
  86. // @ts-expect-error A revoir après que les lignes aient été décommentées
  87. (config.plugins ?? []).push(
  88. vuetify()
  89. // Remplacer par cela quand l'issue https://github.com/vuetifyjs/vuetify-loader/issues/273 sera règlée..
  90. // voir aussi : https://github.com/nuxt/nuxt/issues/15412 et https://github.com/vuetifyjs/vuetify-loader/issues/290
  91. // voir aussi : https://github.com/jrutila/nuxt3-vuetify3-bug
  92. // vuetify({
  93. // styles: { configFile: './assets/css/settings.scss' }
  94. // })
  95. )
  96. )
  97. },
  98. [
  99. '@pinia/nuxt',
  100. {
  101. autoImports: [
  102. // automatically imports `usePinia()`
  103. 'defineStore',
  104. // automatically imports `usePinia()` as `usePiniaStore()`
  105. ['defineStore', 'definePiniaStore'],
  106. ],
  107. },
  108. ],
  109. '@pinia-orm/nuxt',
  110. 'nuxt-lodash',
  111. '@nuxtjs/i18n',
  112. '@nuxt/devtools',
  113. 'nuxt3-leaflet',
  114. '@nuxtjs/google-fonts',
  115. '@nuxtjs/sitemap',
  116. 'nuxt-gtag',
  117. 'nuxt-vitalizer',
  118. ],
  119. router: {
  120. options: {
  121. scrollBehaviorType: 'smooth',
  122. },
  123. },
  124. webfontloader: {
  125. google: {
  126. families: ['Barlow:300,400,500,700&display=swap'],
  127. },
  128. },
  129. devtools: {
  130. // @see https://github.com/nuxt/devtools
  131. enabled: true,
  132. },
  133. vite: {
  134. esbuild: {
  135. drop: process.env.DEBUG ? [] : ['console', 'debugger'],
  136. tsconfigRaw: {
  137. compilerOptions: {
  138. experimentalDecorators: true,
  139. },
  140. },
  141. },
  142. ssr: {
  143. noExternal: ['vuetify'],
  144. },
  145. server: {
  146. https,
  147. // @ts-ignore
  148. port: 443,
  149. hmr: {
  150. protocol: 'wss',
  151. port: 24680,
  152. },
  153. },
  154. },
  155. vuetify: {
  156. styles: { configFile: 'src/vuetify.scss' },
  157. },
  158. i18n: {
  159. langDir: 'lang',
  160. lazy: true,
  161. locales: [
  162. {
  163. code: 'fr',
  164. iso: 'fr-FR',
  165. file: 'fr.json',
  166. name: 'Français',
  167. },
  168. ],
  169. defaultLocale: 'fr',
  170. detectBrowserLanguage: false,
  171. } as NuxtI18nOptions,
  172. build: {
  173. transpile,
  174. },
  175. googleFonts: {
  176. families: {
  177. Barlow: true,
  178. },
  179. display: 'block',
  180. },
  181. gtag: {
  182. id: 'G-L8PZ9TEFNX',
  183. enabled: false,
  184. },
  185. })