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