nuxt.config.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. script: [
  67. // // Google Analytics
  68. // {
  69. // src: 'https://www.googletagmanager.com/gtag/js?id=G-L8PZ9TEFNX',
  70. // async: true,
  71. // },
  72. // {
  73. // innerHTML: `
  74. // window.dataLayer = window.dataLayer || [];
  75. // function gtag(){dataLayer.push(arguments);}
  76. // gtag('js', new Date());
  77. // gtag('config', 'G-L8PZ9TEFNX');
  78. // `,
  79. // type: 'text/javascript',
  80. // },
  81. // // Meta Pixel
  82. // {
  83. // src: 'https://connect.facebook.net/en_US/fbevents.js',
  84. // async: true,
  85. // },
  86. // {
  87. // innerHTML: `
  88. // !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  89. // n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
  90. // n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
  91. // t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
  92. // document,'script','https://connect.facebook.net/en_US/fbevents.js');
  93. // fbq('init', '1045498113172655');
  94. // fbq('track', 'PageView');
  95. // `,
  96. // type: 'text/javascript',
  97. // },
  98. ],
  99. },
  100. },
  101. typescript: {
  102. strict: true,
  103. },
  104. modules: [
  105. // eslint-disable-next-line require-await
  106. async (_, nuxt) => {
  107. nuxt.hooks.hook('vite:extendConfig', (config) =>
  108. // @ts-expect-error A revoir après que les lignes aient été décommentées
  109. (config.plugins ?? []).push(
  110. vuetify()
  111. // Remplacer par cela quand l'issue https://github.com/vuetifyjs/vuetify-loader/issues/273 sera règlée..
  112. // voir aussi : https://github.com/nuxt/nuxt/issues/15412 et https://github.com/vuetifyjs/vuetify-loader/issues/290
  113. // voir aussi : https://github.com/jrutila/nuxt3-vuetify3-bug
  114. // vuetify({
  115. // styles: { configFile: './assets/css/settings.scss' }
  116. // })
  117. )
  118. )
  119. },
  120. [
  121. '@pinia/nuxt',
  122. {
  123. autoImports: [
  124. // automatically imports `usePinia()`
  125. 'defineStore',
  126. // automatically imports `usePinia()` as `usePiniaStore()`
  127. ['defineStore', 'definePiniaStore'],
  128. ],
  129. },
  130. ],
  131. '@pinia-orm/nuxt',
  132. 'nuxt-lodash',
  133. '@nuxtjs/i18n',
  134. '@nuxt/devtools',
  135. 'nuxt3-leaflet',
  136. '@nuxtjs/google-fonts',
  137. '@nuxtjs/sitemap',
  138. ],
  139. router: {
  140. options: {
  141. scrollBehaviorType: 'smooth',
  142. },
  143. },
  144. webfontloader: {
  145. google: {
  146. families: ['Barlow:300,400,500,700&display=swap'],
  147. },
  148. },
  149. devtools: {
  150. // @see https://github.com/nuxt/devtools
  151. enabled: true,
  152. },
  153. vite: {
  154. esbuild: {
  155. drop: process.env.DEBUG ? [] : ['console', 'debugger'],
  156. tsconfigRaw: {
  157. compilerOptions: {
  158. experimentalDecorators: true,
  159. },
  160. },
  161. },
  162. ssr: {
  163. noExternal: ['vuetify'],
  164. },
  165. server: {
  166. https,
  167. // @ts-ignore
  168. port: 443,
  169. hmr: {
  170. protocol: 'wss',
  171. port: 24680,
  172. },
  173. },
  174. },
  175. vuetify: {
  176. styles: { configFile: 'src/vuetify.scss' },
  177. },
  178. i18n: {
  179. langDir: 'lang',
  180. lazy: true,
  181. locales: [
  182. {
  183. code: 'fr',
  184. iso: 'fr-FR',
  185. file: 'fr.json',
  186. name: 'Français',
  187. },
  188. ],
  189. defaultLocale: 'fr',
  190. detectBrowserLanguage: false,
  191. } as NuxtI18nOptions,
  192. build: {
  193. transpile,
  194. },
  195. googleFonts: {
  196. families: {
  197. Barlow: true,
  198. },
  199. display: 'block',
  200. },
  201. })