123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- import { defineConfig, loadEnv, normalizePath } from "vite"
- import { APP_INFO, META_TAGS } from "./meta"
- import { viteStaticCopy as StaticCopy } from "vite-plugin-static-copy"
- import generateSitemap from "vite-plugin-pages-sitemap"
- import HtmlConfig from "vite-plugin-html-config"
- import Vue from "@vitejs/plugin-vue"
- import VueI18n from "@intlify/vite-plugin-vue-i18n"
- import Components from "unplugin-vue-components/vite"
- import Icons from "unplugin-icons/vite"
- import Inspect from "vite-plugin-inspect"
- import { VitePWA } from "vite-plugin-pwa"
- import Pages from "vite-plugin-pages"
- import Layouts from "vite-plugin-vue-layouts"
- import IconResolver from "unplugin-icons/resolver"
- import { FileSystemIconLoader } from "unplugin-icons/loaders"
- import * as path from "path"
- import legacy from "@vitejs/plugin-legacy"
- import Unfonts from "unplugin-fonts/vite"
- const ENV = loadEnv("development", path.resolve(__dirname, "../../"))
- export default defineConfig({
- envDir: path.resolve(__dirname, "../../"),
- // TODO: Migrate @hoppscotch/data to full ESM
- define: {
- // For 'util' polyfill required by dep of '@apidevtools/swagger-parser'
- "process.env": {},
- },
- server: {
- port: 3000,
- },
- preview: {
- port: 3000,
- },
- publicDir: path.resolve(__dirname, "../hoppscotch-common/public"),
- build: {
- sourcemap: true,
- emptyOutDir: true,
- rollupOptions: {
- maxParallelFileOps: 2,
- },
- },
- resolve: {
- alias: {
- // TODO: Maybe leave ~ only for individual apps and not use on common
- "~": path.resolve(__dirname, "../hoppscotch-common/src"),
- "@hoppscotch/common": "@hoppscotch/common/src",
- "@composables": path.resolve(
- __dirname,
- "../hoppscotch-common/src/composables"
- ),
- "@modules": path.resolve(__dirname, "../hoppscotch-common/src/modules"),
- "@components": path.resolve(
- __dirname,
- "../hoppscotch-common/src/components"
- ),
- "@helpers": path.resolve(__dirname, "../hoppscotch-common/src/helpers"),
- "@functional": path.resolve(
- __dirname,
- "../hoppscotch-common/src/helpers/functional"
- ),
- "@workers": path.resolve(__dirname, "../hoppscotch-common/src/workers"),
- "@platform": path.resolve(__dirname, "./src/platform"),
- "@lib": path.resolve(__dirname, "./src/lib"),
- stream: "stream-browserify",
- util: "util",
- },
- dedupe: ["vue"],
- },
- plugins: [
- Inspect(), // go to url -> /__inspect
- HtmlConfig({
- metas: META_TAGS(ENV),
- }),
- Vue(),
- Pages({
- routeStyle: "nuxt",
- dirs: "../hoppscotch-common/src/pages",
- importMode: "async",
- onRoutesGenerated(routes) {
- return ((generateSitemap as any) as typeof generateSitemap)({
- routes,
- nuxtStyle: true,
- allowRobots: true,
- dest: ".sitemap-gen",
- hostname: ENV.VITE_BASE_URL,
- })
- },
- }),
- StaticCopy({
- targets: [
- {
- src: normalizePath(path.resolve(__dirname, "./.sitemap-gen/*")),
- dest: normalizePath(path.resolve(__dirname, "./dist")),
- },
- ],
- }),
- Layouts({
- layoutsDirs: "../hoppscotch-common/src/layouts",
- defaultLayout: "default",
- }),
- VueI18n({
- runtimeOnly: false,
- compositionOnly: true,
- include: [path.resolve(__dirname, "locales")],
- }),
- Components({
- dts: "../hoppscotch-common/src/components.d.ts",
- dirs: [
- "../hoppscotch-common/src/components",
- ],
- directoryAsNamespace: true,
- resolvers: [
- IconResolver({
- prefix: "icon",
- customCollections: ["hopp", "auth", "brands"],
- }),
- (compName: string) => {
- if (compName.startsWith("Hopp"))
- return { name: compName, from: "@hoppscotch/ui" }
- else return undefined
- },
- ],
- types: [
- {
- from: "vue-tippy",
- names: ["Tippy"],
- },
- ],
- }),
- Icons({
- compiler: "vue3",
- customCollections: {
- hopp: FileSystemIconLoader("../hoppscotch-common/assets/icons"),
- auth: FileSystemIconLoader("../hoppscotch-common/assets/icons/auth"),
- brands: FileSystemIconLoader(
- "../hoppscotch-common/assets/icons/brands"
- ),
- },
- }),
- VitePWA({
- manifest: {
- name: APP_INFO.name,
- short_name: APP_INFO.name,
- description: APP_INFO.shortDescription,
- start_url: "/?source=pwa",
- background_color: APP_INFO.app.background,
- theme_color: APP_INFO.app.background,
- icons: [
- {
- src: "/icon.png",
- sizes: "512x512",
- type: "image/png",
- purpose: "any maskable",
- },
- {
- src: "/logo.svg",
- sizes: "48x48 72x72 96x96 128x128 256x256 512x512",
- type: "image/svg+xml",
- purpose: "any maskable",
- },
- ],
- },
- registerType: "prompt",
- workbox: {
- cleanupOutdatedCaches: true,
- maximumFileSizeToCacheInBytes: 4194304,
- navigateFallbackDenylist: [
- /robots.txt/,
- /sitemap.xml/,
- /discord/,
- /telegram/,
- /beta/,
- /careers/,
- /newsletter/,
- /twitter/,
- /github/,
- /announcements/,
- ],
- },
- }),
- Unfonts({
- fontsource: {
- families: [
- {
- name: "Inter Variable",
- variables: ["variable-full"],
- },
- {
- name: "Material Symbols Rounded Variable",
- variables: ["variable-full"],
- },
- {
- name: "Roboto Mono Variable",
- variables: ["variable-full"],
- },
- ],
- },
- }),
- legacy({
- modernPolyfills: ["es.string.replace-all"],
- renderLegacyChunks: false,
- }),
- ],
- })
|