nuxt.config.ts 5.0 KB

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