nuxt.config.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. // eslint-disable-next-line require-await
  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. ],
  163. vite: {
  164. esbuild: {
  165. drop: process.env.DEBUG ? [] : ['console', 'debugger'],
  166. tsconfigRaw: {
  167. compilerOptions: {
  168. experimentalDecorators: true,
  169. },
  170. },
  171. },
  172. ssr: {
  173. // with ssr enabled, this config is required to load vuetify properly
  174. noExternal: ['vuetify'],
  175. },
  176. server: {
  177. https,
  178. // @ts-expect-error J'ignore pourquoi cette erreur TS se produit, cette propriété est valide
  179. port: 443,
  180. hmr: {
  181. protocol: 'wss',
  182. port: 24678,
  183. },
  184. },
  185. },
  186. // Hide the sourcemaps warnings with vuetify
  187. // @see https://github.com/vuetifyjs/vuetify-loader/issues/290#issuecomment-1435702713
  188. sourcemap: {
  189. server: false,
  190. client: false,
  191. },
  192. i18n: {
  193. langDir: 'lang',
  194. lazy: true,
  195. strategy: 'no_prefix',
  196. locales: [
  197. {
  198. code: 'en',
  199. iso: 'en-US',
  200. file: 'en.json',
  201. name: 'English',
  202. },
  203. {
  204. code: 'fr',
  205. iso: 'fr-FR',
  206. file: 'fr.json',
  207. name: 'Français',
  208. },
  209. ],
  210. defaultLocale: 'fr',
  211. detectBrowserLanguage: false,
  212. vueI18n: './i18n.config.ts',
  213. },
  214. image: {
  215. provider: 'none',
  216. },
  217. build: {
  218. transpile,
  219. },
  220. ignore: [process.env.NUXT_ENV === 'prod' ? 'pages/dev/*' : ''],
  221. prepare: {
  222. scripts: ['prepare/buildIndex.ts'],
  223. },
  224. compatibilityDate: '2025-03-10',
  225. })