nuxt.config.ts 4.2 KB

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