nuxt.config.ts 4.3 KB

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