nuxt.config.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. supportUrl: '',
  43. // Config within public will be also exposed to the client
  44. public: {
  45. env: '',
  46. baseUrl: '',
  47. baseUrlLegacy: '',
  48. baseUrlAdminLegacy: '',
  49. baseUrlTypo3: '',
  50. baseUrlMercure: '',
  51. supportUrl: '',
  52. },
  53. },
  54. hooks: {
  55. 'builder:watch': console.log,
  56. },
  57. app: {
  58. head: {
  59. title: 'Opentalent',
  60. meta: [
  61. { charset: 'utf-8' },
  62. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  63. { name: 'msapplication-TileColor', content: '#324250' },
  64. {
  65. name: 'msapplication-TileImage',
  66. content: '/favicon/mstile-144x144.png',
  67. },
  68. ],
  69. link: [
  70. { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
  71. {
  72. rel: 'apple-touch-icon-precomposed',
  73. sizes: '57x57',
  74. href: '/favicon/apple-touch-icon-57x57.png',
  75. },
  76. {
  77. rel: 'apple-touch-icon-precomposed',
  78. sizes: '114x114',
  79. href: '/favicon/apple-touch-icon-114x114.png',
  80. },
  81. {
  82. rel: 'apple-touch-icon-precomposed',
  83. sizes: '72x72',
  84. href: '/favicon/apple-touch-icon-72x72.png',
  85. },
  86. {
  87. rel: 'apple-touch-icon-precomposed',
  88. sizes: '144x144',
  89. href: '/favicon/apple-touch-icon-144x144.png',
  90. },
  91. {
  92. rel: 'apple-touch-icon-precomposed',
  93. sizes: '120x120',
  94. href: '/favicon/apple-touch-icon-120x120.png',
  95. },
  96. {
  97. rel: 'apple-touch-icon-precomposed',
  98. sizes: '152x152',
  99. href: '/favicon/apple-touch-icon-152x152.png',
  100. },
  101. {
  102. rel: 'icon',
  103. sizes: '32x32',
  104. type: 'image/x-icon',
  105. href: '/favicon/favicon-32x32.png',
  106. },
  107. {
  108. rel: 'icon',
  109. sizes: '16x16',
  110. type: 'image/x-icon',
  111. href: '/favicon/favicon-16x16.png',
  112. },
  113. ],
  114. },
  115. },
  116. css: [
  117. '@/assets/css/global.scss',
  118. '@/assets/css/theme.scss',
  119. '@/assets/css/import.scss',
  120. '@vuepic/vue-datepicker/dist/main.css',
  121. ],
  122. typescript: {
  123. strict: true,
  124. },
  125. modules: [
  126. // eslint-disable-next-line require-await
  127. async (_, nuxt) => {
  128. nuxt.hooks.hook('vite:extendConfig', (config) =>
  129. // @ts-expect-error A revoir après que les lignes aient été décommentées
  130. (config.plugins ?? []).push(
  131. vuetify(),
  132. // Remplacer par cela quand l'issue https://github.com/vuetifyjs/vuetify-loader/issues/273 sera règlée..
  133. // voir aussi : https://github.com/nuxt/nuxt/issues/15412 et https://github.com/vuetifyjs/vuetify-loader/issues/290
  134. // voir aussi : https://github.com/jrutila/nuxt3-vuetify3-bug
  135. // vuetify({
  136. // styles: { configFile: './assets/css/settings.scss' }
  137. // })
  138. ),
  139. )
  140. },
  141. [
  142. '@pinia/nuxt',
  143. {
  144. autoImports: [
  145. // automatically imports `usePinia()`
  146. 'defineStore',
  147. // automatically imports `usePinia()` as `usePiniaStore()`
  148. ['defineStore', 'definePiniaStore'],
  149. ],
  150. },
  151. ],
  152. '@pinia-orm/nuxt',
  153. '@nuxtjs/i18n',
  154. '@nuxt/devtools',
  155. '@nuxt/image',
  156. ],
  157. vite: {
  158. esbuild: {
  159. drop: process.env.DEBUG ? [] : ['console', 'debugger'],
  160. tsconfigRaw: {
  161. compilerOptions: {
  162. experimentalDecorators: true,
  163. },
  164. },
  165. },
  166. ssr: {
  167. // with ssr enabled, this config is required to load vuetify properly
  168. noExternal: ['vuetify'],
  169. },
  170. server: {
  171. https,
  172. // @ts-expect-error J'ignore pourquoi cette erreur TS se produit, cette propriété est valide
  173. port: 443,
  174. hmr: {
  175. protocol: 'wss',
  176. port: 24678,
  177. },
  178. },
  179. },
  180. // Hide the sourcemaps warnings with vuetify
  181. // @see https://github.com/vuetifyjs/vuetify-loader/issues/290#issuecomment-1435702713
  182. sourcemap: {
  183. server: false,
  184. client: false,
  185. },
  186. i18n: {
  187. langDir: 'lang',
  188. lazy: true,
  189. locales: [
  190. {
  191. code: 'en',
  192. iso: 'en-US',
  193. file: 'en.json',
  194. name: 'English',
  195. },
  196. {
  197. code: 'fr',
  198. iso: 'fr-FR',
  199. file: 'fr.json',
  200. name: 'Français',
  201. },
  202. ],
  203. defaultLocale: 'fr',
  204. detectBrowserLanguage: false,
  205. vueI18n: './i18n.config.ts',
  206. },
  207. image: {
  208. provider: 'none',
  209. },
  210. build: {
  211. transpile,
  212. },
  213. })