quasar.config.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /* eslint-env node */
  2. // Configuration for your app
  3. // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js
  4. import { defineConfig } from "#q-app/wrappers";
  5. import { existsSync, readFileSync } from "node:fs";
  6. import { resolve } from "node:path";
  7. import { fileURLToPath } from "node:url";
  8. const envFiles = {
  9. dev: ".env.app.dev",
  10. staging: ".env.app.staging",
  11. prod: ".env.app.prod",
  12. };
  13. const parseEnvFile = (filePath) => {
  14. if (!existsSync(filePath)) {
  15. return {};
  16. }
  17. return readFileSync(filePath, "utf8")
  18. .split(/\r?\n/)
  19. .reduce((env, line) => {
  20. const trimmedLine = line.trim();
  21. if (!trimmedLine || trimmedLine.startsWith("#")) {
  22. return env;
  23. }
  24. const separatorIndex = trimmedLine.indexOf("=");
  25. if (separatorIndex === -1) {
  26. return env;
  27. }
  28. const key = trimmedLine.slice(0, separatorIndex).trim();
  29. const value = trimmedLine.slice(separatorIndex + 1).trim();
  30. env[key] = value.replace(/^["']|["']$/g, "");
  31. return env;
  32. }, {});
  33. };
  34. const loadAppEnv = (ctx) => {
  35. const appEnv = process.env.APP_ENV || (ctx.dev ? "dev" : "prod");
  36. const envFile = envFiles[appEnv];
  37. if (!envFile) {
  38. throw new Error(`APP_ENV invalido: "${appEnv}". Use dev, staging ou prod.`);
  39. }
  40. const fileEnv = parseEnvFile(resolve(process.cwd(), envFile));
  41. return {
  42. APP_ENV: appEnv,
  43. API_URL: process.env.API_URL || fileEnv.API_URL || "http://localhost:3000",
  44. PASSWORD: process.env.PASSWORD || fileEnv.PASSWORD || "",
  45. SENHA: process.env.SENHA || fileEnv.SENHA || "",
  46. WEBSOCKET_API:
  47. process.env.WEBSOCKET_API ||
  48. fileEnv.WEBSOCKET_API ||
  49. "http://localhost:4321/",
  50. WEBSOCKET_PATH:
  51. process.env.WEBSOCKET_PATH || fileEnv.WEBSOCKET_PATH || "/socket.io",
  52. WEBSOCKET_ROOM:
  53. process.env.WEBSOCKET_ROOM || fileEnv.WEBSOCKET_ROOM || "LARAVEL",
  54. WEBSOCKET_API_KEY:
  55. process.env.WEBSOCKET_API_KEY || fileEnv.WEBSOCKET_API_KEY || "",
  56. };
  57. };
  58. export default defineConfig((ctx) => {
  59. const appEnv = loadAppEnv(ctx);
  60. return {
  61. // https://v2.quasar.dev/quasar-cli-vite/prefetch-feature
  62. // preFetch: true,
  63. // app boot file (/src/boot)
  64. // --> boot files are part of "main.js"
  65. // https://v2.quasar.dev/quasar-cli-vite/boot-files
  66. boot: [
  67. "axios",
  68. "i18n",
  69. "defaultPropsComponents",
  70. // "socket.io",
  71. ],
  72. // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
  73. css: ["app.scss"],
  74. // https://github.com/quasarframework/quasar/tree/dev/extras
  75. extras: [
  76. // 'ionicons-v4',
  77. "mdi-v7",
  78. // 'fontawesome-v6',
  79. // 'eva-icons',
  80. // 'themify',
  81. // "line-awesome",
  82. // 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
  83. "roboto-font", // optional, you are not bound to it
  84. "material-icons", // optional, you are not bound to it
  85. ],
  86. // Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
  87. build: {
  88. target: {
  89. browser: ["es2022", "firefox115", "chrome115", "safari14"],
  90. node: "node22",
  91. },
  92. vueRouterMode: "history", // available values: 'hash', 'history'
  93. // vueRouterBase,
  94. // vueDevtools,
  95. // vueOptionsAPI: false,
  96. // rebuildCache: true, // rebuilds Vite/linter/etc cache on startup
  97. // publicPath: '/',
  98. // analyze: true,
  99. env: appEnv,
  100. // rawDefine: {}
  101. // ignorePublicFolder: true,
  102. // minify: false,
  103. // polyfillModulePreload: true,
  104. // distDir
  105. // extendViteConf (viteConf) {},
  106. // viteVuePluginOptions: {},
  107. vitePlugins: [
  108. [
  109. "@intlify/unplugin-vue-i18n/vite",
  110. {
  111. include: [fileURLToPath(new URL("./src/i18n", import.meta.url))],
  112. ssr: ctx.modeName === "ssr",
  113. },
  114. ],
  115. [
  116. "vite-plugin-checker",
  117. {
  118. eslint: {
  119. lintCommand:
  120. 'eslint -c ./eslint.config.js "./src*/**/*.{js,mjs,cjs,vue}"',
  121. useFlatConfig: true,
  122. },
  123. },
  124. { server: false },
  125. ],
  126. ],
  127. },
  128. // Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#devServer
  129. devServer: {
  130. // https: true
  131. open: false, // opens browser window automatically
  132. },
  133. // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
  134. framework: {
  135. lang: "pt-BR",
  136. config: {
  137. dark: "auto",
  138. notify: {
  139. position: "top-right",
  140. },
  141. },
  142. // iconSet: 'material-icons', // Quasar icon set
  143. // lang: 'en-US', // Quasar language pack
  144. // For special cases outside of where the auto-import strategy can have an impact
  145. // (like functional components as one of the examples),
  146. // you can manually specify Quasar components/directives to be available everywhere:
  147. //
  148. // components: [],
  149. // directives: [],
  150. // Quasar plugins
  151. plugins: ["Dialog", "Notify", "Loading", "Cookies", "Dark"],
  152. },
  153. // animations: 'all', // --- includes all animations
  154. // https://v2.quasar.dev/options/animations
  155. animations: [],
  156. // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#property-sourcefiles
  157. // sourceFiles: {
  158. // rootComponent: 'src/App.vue',
  159. // router: 'src/router/index',
  160. // store: 'src/store/index',
  161. // pwaRegisterServiceWorker: 'src-pwa/register-service-worker',
  162. // pwaServiceWorker: 'src-pwa/custom-service-worker',
  163. // pwaManifestFile: 'src-pwa/manifest.json',
  164. // electronMain: 'src-electron/electron-main',
  165. // electronPreload: 'src-electron/electron-preload'
  166. // bexManifestFile: 'src-bex/manifest.json
  167. // },
  168. // https://v2.quasar.dev/quasar-cli-vite/developing-ssr/configuring-ssr
  169. ssr: {
  170. prodPort: 3000, // The default port that the production server should use
  171. // (gets superseded if process.env.PORT is specified at runtime)
  172. middlewares: [
  173. "render", // keep this as last one
  174. ],
  175. // extendPackageJson (json) {},
  176. // extendSSRWebserverConf (esbuildConf) {},
  177. // manualStoreSerialization: true,
  178. // manualStoreSsrContextInjection: true,
  179. // manualStoreHydration: true,
  180. // manualPostHydrationTrigger: true,
  181. pwa: false,
  182. // pwaOfflineHtmlFilename: 'offline.html', // do NOT use index.html as name!
  183. // will mess up SSR
  184. // pwaExtendGenerateSWOptions (cfg) {},
  185. // pwaExtendInjectManifestOptions (cfg) {}
  186. },
  187. // https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
  188. pwa: {
  189. workboxMode: "GenerateSW", // 'GenerateSW' or 'InjectManifest'
  190. // swFilename: 'sw.js',
  191. // manifestFilename: 'manifest.json'
  192. // extendManifestJson (json) {},
  193. // useCredentialsForManifestTag: true,
  194. // injectPwaMetaTags: false,
  195. // extendPWACustomSWConf (esbuildConf) {},
  196. // extendGenerateSWOptions (cfg) {},
  197. // extendInjectManifestOptions (cfg) {}
  198. },
  199. // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-cordova-apps/configuring-cordova
  200. cordova: {
  201. // noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
  202. },
  203. // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-capacitor-apps/configuring-capacitor
  204. capacitor: {
  205. hideSplashscreen: true,
  206. },
  207. // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-electron-apps/configuring-electron
  208. electron: {
  209. // extendElectronMainConf (esbuildConf) {},
  210. // extendElectronPreloadConf (esbuildConf) {},
  211. // extendPackageJson (json) {},
  212. // Electron preload scripts (if any) from /src-electron, WITHOUT file extension
  213. preloadScripts: ["electron-preload"],
  214. // specify the debugging port to use for the Electron app when running in development mode
  215. inspectPort: 5858,
  216. bundler: "packager", // 'packager' or 'builder'
  217. packager: {
  218. // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
  219. // OS X / Mac App Store
  220. // appBundleId: '',
  221. // appCategoryType: '',
  222. // osxSign: '',
  223. // protocol: 'myapp://path',
  224. // Windows only
  225. // win32metadata: { ... }
  226. },
  227. builder: {
  228. // https://www.electron.build/configuration/configuration
  229. appId: "quasar-skeleton",
  230. },
  231. },
  232. // Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
  233. bex: {
  234. // extendBexScriptsConf (esbuildConf) {},
  235. // extendBexManifestJson (json) {},
  236. contentScripts: ["my-content-script"],
  237. },
  238. };
  239. });