nuxt.config.ts 4.4 KB

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