nuxt.config.ts 5.8 KB

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