quasar.config.js 8.6 KB

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