quasar.config.js 8.6 KB

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