quasar.config.js 8.4 KB

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