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