nuxt.config.ts 5.2 KB

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