nuxt.config.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. import fs from 'fs'
  2. import vuetify from 'vite-plugin-vuetify'
  3. import { defineNuxtConfig } from 'nuxt/config'
  4. let https = {}
  5. const transpile = [
  6. 'vuetify',
  7. '@vuepic/vue-datepicker',
  8. 'pinia',
  9. 'pinia-orm',
  10. 'date-fns',
  11. 'v-phone-input',
  12. ]
  13. if (!process.env.NUXT_ENV) {
  14. throw new Error('Missing environment file - Run yarn install')
  15. }
  16. if (process.env.NUXT_ENV === 'dev') {
  17. https = {
  18. key: fs.readFileSync('env/local.app.opentalent.fr.key'),
  19. cert: fs.readFileSync('env/local.app.opentalent.fr.crt'),
  20. }
  21. } else {
  22. transpile.push('lodash')
  23. }
  24. /**
  25. * Nuxt configuration
  26. *
  27. * @see https://nuxt.com/docs/api/configuration/nuxt-config
  28. */
  29. export default defineNuxtConfig({
  30. ssr: true,
  31. experimental: {
  32. // Fix the 'Cannot stringify non POJO' bug
  33. // @see https://github.com/nuxt/nuxt/issues/20787
  34. renderJsonPayloads: false,
  35. },
  36. runtimeConfig: {
  37. // Private config that is only available on the server
  38. env: '',
  39. baseUrl: '',
  40. baseUrlLegacy: '',
  41. baseUrlAdminLegacy: '',
  42. baseUrlTypo3: '',
  43. baseUrlMercure: '',
  44. fileStorageBaseUrl: '',
  45. supportUrl: '',
  46. // Config within public will be also exposed to the client
  47. public: {
  48. env: '',
  49. baseUrl: '',
  50. baseUrlLegacy: '',
  51. baseUrlAdminLegacy: '',
  52. baseUrlTypo3: '',
  53. baseUrlMercure: '',
  54. fileStorageBaseUrl: '',
  55. supportUrl: '',
  56. },
  57. },
  58. hooks: {
  59. 'builder:watch': console.log,
  60. },
  61. app: {
  62. head: {
  63. title: 'Opentalent',
  64. meta: [
  65. { charset: 'utf-8' },
  66. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  67. { name: 'msapplication-TileColor', content: '#324250' },
  68. {
  69. name: 'msapplication-TileImage',
  70. content: '/favicon/favicon-144x144.png',
  71. },
  72. ],
  73. link: [
  74. { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
  75. {
  76. rel: 'apple-touch-icon-precomposed',
  77. sizes: '57x57',
  78. href: '/favicon/apple-touch-icon-57x57.png',
  79. },
  80. {
  81. rel: 'apple-touch-icon-precomposed',
  82. sizes: '114x114',
  83. href: '/favicon/apple-touch-icon-114x114.png',
  84. },
  85. {
  86. rel: 'apple-touch-icon-precomposed',
  87. sizes: '72x72',
  88. href: '/favicon/apple-touch-icon-72x72.png',
  89. },
  90. {
  91. rel: 'apple-touch-icon-precomposed',
  92. sizes: '144x144',
  93. href: '/favicon/apple-touch-icon-144x144.png',
  94. },
  95. {
  96. rel: 'apple-touch-icon-precomposed',
  97. sizes: '120x120',
  98. href: '/favicon/apple-touch-icon-120x120.png',
  99. },
  100. {
  101. rel: 'apple-touch-icon-precomposed',
  102. sizes: '152x152',
  103. href: '/favicon/apple-touch-icon-152x152.png',
  104. },
  105. {
  106. rel: 'icon',
  107. sizes: '32x32',
  108. type: 'image/x-icon',
  109. href: '/favicon/favicon-32x32.png',
  110. },
  111. {
  112. rel: 'icon',
  113. sizes: '16x16',
  114. type: 'image/x-icon',
  115. href: '/favicon/favicon-16x16.png',
  116. },
  117. ],
  118. },
  119. },
  120. css: [
  121. '@/assets/css/global.scss',
  122. '@/assets/css/theme.scss',
  123. '@/assets/css/import.scss',
  124. '@vuepic/vue-datepicker/dist/main.css',
  125. '@/assets/css/vue-date-picker.scss',
  126. ],
  127. typescript: {
  128. strict: false,
  129. },
  130. imports: {
  131. autoImport: true,
  132. },
  133. modules: [
  134. async (_, nuxt) => {
  135. nuxt.hooks.hook('vite:extendConfig', (config) =>
  136. // @ts-expect-error A revoir après que les lignes aient été décommentées
  137. (config.plugins ?? []).push(
  138. vuetify(),
  139. // Remplacer par cela quand l'issue https://github.com/vuetifyjs/vuetify-loader/issues/273 sera règlée..
  140. // voir aussi : https://github.com/nuxt/nuxt/issues/15412 et https://github.com/vuetifyjs/vuetify-loader/issues/290
  141. // voir aussi : https://github.com/jrutila/nuxt3-vuetify3-bug
  142. // vuetify({
  143. // styles: { configFile: './assets/css/settings.scss' }
  144. // })
  145. ),
  146. )
  147. },
  148. [
  149. '@pinia/nuxt',
  150. {
  151. autoImports: [
  152. // automatically imports `usePinia()`
  153. 'defineStore',
  154. // automatically imports `usePinia()` as `usePiniaStore()`
  155. ['defineStore', 'definePiniaStore'],
  156. ],
  157. },
  158. ],
  159. '@pinia-orm/nuxt',
  160. '@nuxtjs/i18n',
  161. '@nuxt/devtools',
  162. '@nuxt/image',
  163. 'nuxt-prepare',
  164. 'nuxt-vitalizer',
  165. '@nuxt/eslint',
  166. '@nuxtjs/leaflet',
  167. ],
  168. vite: {
  169. esbuild: {
  170. drop: process.env.DEBUG ? [] : ['console', 'debugger'],
  171. tsconfigRaw: {
  172. compilerOptions: {
  173. experimentalDecorators: true,
  174. },
  175. },
  176. },
  177. ssr: {
  178. // with ssr enabled, this config is required to load vuetify properly
  179. noExternal: ['vuetify'],
  180. },
  181. server: {
  182. https,
  183. // @ts-expect-error J'ignore pourquoi cette erreur TS se produit, cette propriété est valide
  184. port: 443,
  185. hmr: {
  186. protocol: 'wss',
  187. port: 24678,
  188. },
  189. },
  190. },
  191. // Hide the sourcemaps warnings with vuetify
  192. // @see https://github.com/vuetifyjs/vuetify-loader/issues/290#issuecomment-1435702713
  193. sourcemap: {
  194. server: false,
  195. client: false,
  196. },
  197. i18n: {
  198. langDir: 'lang',
  199. lazy: true,
  200. strategy: 'no_prefix',
  201. locales: [
  202. {
  203. code: 'en',
  204. iso: 'en-US',
  205. file: 'en.json',
  206. name: 'English',
  207. },
  208. {
  209. code: 'fr',
  210. iso: 'fr-FR',
  211. files: [
  212. 'fr/general.json',
  213. 'fr/event_categories.json',
  214. 'fr/breadcrumbs.json',
  215. ],
  216. name: 'Français',
  217. },
  218. ],
  219. defaultLocale: 'fr',
  220. detectBrowserLanguage: false,
  221. vueI18n: './i18n.config.ts',
  222. },
  223. image: {
  224. provider: 'none',
  225. },
  226. build: {
  227. transpile,
  228. },
  229. ignore: [process.env.NUXT_ENV === 'prod' ? 'pages/dev/*' : ''],
  230. prepare: {
  231. scripts: ['prepare/buildIndex.ts', 'prepare/compileAbilitiesConfig.ts'],
  232. },
  233. compatibilityDate: '2025-03-10',
  234. })