import { UserConfig as ViteUserConfig } from "vite"; import { Options as VuePluginOptions } from "@vitejs/plugin-vue" import { QuasarHookParams } from "./conf"; interface InvokeParams { isClient: boolean; isServer: boolean; } interface BuildTargetOptions { /** * @default ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'] */ browser?: string[]; /** * @example 'node16' */ node: string; } interface QuasarStaticBuildConfiguration { /** * @example * { * browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'], * node: 'node16' * } */ target?: BuildTargetOptions; /** * Extend Vite config generated by Quasar CLI. */ extendViteConf?: ( config: ViteUserConfig, invokeParams: InvokeParams ) => void; /** * Options to supply to @vitejs/plugin-vue */ viteVuePluginOptions?: VuePluginOptions; /** * Vite plugins * * @example * [ * [ 'package-name', { ..options.. } ], * [ require('some-plugin'), { ...options... } ] * ] */ vitePlugins?: object[]; /** * @example setting an alias for a custom folder * { * locales: path.join(__dirname, 'src/locales') * } */ alias?: object[]; /** * Public path of your app. * Use it when your public path is something else, * like _“:///some/nested/folder”_ – in this case, * it means the distributables are in _“some/nested/folder”_ on your webserver. * * @default '/' */ publicPath?: string; /** * Sets [Vue Router mode](https://router.vuejs.org/guide/essentials/history-mode.html). * History mode requires configuration on your deployment web server too. * * @default 'hash' */ vueRouterMode?: "hash" | "history"; /** * Sets Vue Router base. * Should not need to configure this, unless absolutely needed. */ vueRouterBase?: string; /** * Should the Vue Options API be available? * @default true */ vueOptionsAPI?: boolean; /** * Should we invalidate the Vite and ESLint cache on startup? * @default false */ rebuildCache?: boolean; /** * Do you want to analyze the production bundles? * Generates and opens an html report. * @default false */ analyze?: boolean; /** * Folder where Quasar CLI should generate the distributables. * Relative path to project root directory. * * @default 'dist/{ctx.modeName}' For all modes except Cordova. * @default 'src-cordova/www' For Cordova mode. */ distDir?: string; /** * Add properties to `process.env` that you can use in your website/app JS code. * * @example { SOMETHING: 'someValue' } */ env?: { [index: string]: string }; /** * Defines constants that get replaced in your app. * * @example { SOMETHING: JSON.stringify('someValue') } -> console.log(SOMETHING) // console.log('someValue') */ rawDefine?: { [index: string]: string }; /** * Build production assets with or without the hash part in filenames. * Example: "454d87bd" in "assets/index.454d87bd.js" * * When used, please be careful how you configure your web server cache strategy as * files will not change name so your client might get 304 (Not Modified) even when * it's not the case. * * Will not change anything if your Vite config already touches the * build.rollupOptions.output.entryFileNames/chunkFileNames/assetFileNames props. * * Gets applied to production builds only. * * Useful especially for (but not restricted to) PWA. If set to false then updating the * PWA will force to re-download all assets again, regardless if they were changed or * not (due to how Rollup works through Vite). * * @default true */ useFilenameHashes?: boolean; /** * whether to inject module preload polyfill. * @default false */ polyfillModulePreload?: boolean; /** * Ignores the public folder. * @default false */ ignorePublicFolder?: boolean; /** * Treeshake Quasar's UI on dev too? * Recommended to leave this as false for performance reasons. * @default false */ devQuasarTreeshaking?: boolean; /** * Prepare external services before `$ quasar dev` command runs * like starting some backend or any other service that the app relies on. * Can use async/await or directly return a Promise. */ beforeDev?: (params: QuasarHookParams) => void; /** * Run hook after Quasar dev server is started (`$ quasar dev`). * At this point, the dev server has been started and is available should you wish to do something with it. * Can use async/await or directly return a Promise. */ afterDev?: (params: QuasarHookParams) => void; /** * Run hook before Quasar builds app for production (`$ quasar build`). * At this point, the distributables folder hasn’t been created yet. * Can use async/await or directly return a Promise. */ beforeBuild?: (params: QuasarHookParams) => void; /** * Run hook after Quasar built app for production (`$ quasar build`). * At this point, the distributables folder has been created and is available * should you wish to do something with it. * Can use async/await or directly return a Promise. */ afterBuild?: (params: QuasarHookParams) => void; /** * Run hook if publishing was requested (`$ quasar build -P`), * after Quasar built app for production and the afterBuild hook (if specified) was executed. * Can use async/await or directly return a Promise. * `opts` is Object of form `{arg, distDir}`, * where “arg” is the argument supplied (if any) to -P parameter. */ onPublish?: (ops: { arg: string; distDir: string }) => void; } /** * Following properties of `build` are automatically configured by Quasar CLI * depending on dev/build commands and Quasar mode. * You can override some, but make sure you know what you are doing. */ interface QuasarDynamicBuildConfiguration { /** * Set to `false` to disable minification, or specify the minifier to use. * Available options are 'terser' or 'esbuild'. * If set to anything but boolean false then it also applies to CSS. * For production only. * @default 'esbuild' */ minify?: boolean | 'terser' | 'esbuild'; /** * If `true`, a separate sourcemap file will be created. If 'inline', the * sourcemap will be appended to the resulting output file as data URI. * 'hidden' works like `true` except that the corresponding sourcemap * comments in the bundled files are suppressed. * @default false */ sourcemap?: boolean | 'inline' | 'hidden'; } export type QuasarBuildConfiguration = QuasarStaticBuildConfiguration & QuasarDynamicBuildConfiguration;