quasar.config.js 8.3 KB

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