nuxt.config.ts 4.4 KB

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