quasar.config.js 8.3 KB

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