nuxt.config.ts 5.6 KB

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