nuxt.config.ts 5.2 KB

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