From 4596080a9aa994722cf3cd24aca21b5e0155223c Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 25 Jun 2024 22:21:05 +0800 Subject: [PATCH] Chore: fix vite import deps (local against github source) (#58) * chore: fix vite import deps (local against github source) --- layer/nuxt-config/vite/index.ts | 55 +++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/layer/nuxt-config/vite/index.ts b/layer/nuxt-config/vite/index.ts index 9a6aaac9..14cd861d 100644 --- a/layer/nuxt-config/vite/index.ts +++ b/layer/nuxt-config/vite/index.ts @@ -4,9 +4,29 @@ import { ViteConfig } from '@nuxt/schema' import { createResolver } from '@nuxt/kit' import { nodePolyfills } from '@bangjelkoski/vite-plugin-node-polyfills' +const isLocalLayer = process.env.LOCAL_LAYER === 'true' +const isProduction = process.env.NODE_ENV === 'production' + const buildSourceMap = process.env.BUILD_SOURCEMAP !== 'false' const { resolve } = createResolver(import.meta.url) +// deps affecting local build against github source +const additionalDeps = [ + 'bs58', + 'bn.js', + 'eventemitter3', + '@solana/web3.js', + '@cosmjs/stargate', + '@cosmjs/launchpad', + '@solana/buffer-layout', + '@injectivelabs/grpc-web', + 'jayson/lib/client/browser', + '@cosmostation/extension-client', + 'jayson/lib/client/browser/index', + '@cosmostation/extension-client/error', + '@cosmostation/extension-client/index' +] + export default defineConfig({ plugins: [tsconfigPaths(), nodePolyfills({ protocolImports: true })], @@ -49,22 +69,25 @@ export default defineConfig({ }, optimizeDeps: { - include: [ - 'date-fns', - 'vue-imask', - 'vue-hotjar', - 'apexcharts', - 'lottie-web', - 'js-confetti', - 'date-fns-tz', - 'floating-vue', - 'canvas-confetti', - 'lightweight-charts', - '@injectivelabs/utils', - '@injectivelabs/sdk-ts', - '@injectivelabs/wallet-ts', - '@vueuse/integrations/useQRCode' - ], + include: isProduction + ? [] + : [ + 'date-fns', + 'vue-imask', + 'vue-hotjar', + 'apexcharts', + 'lottie-web', + 'js-confetti', + 'date-fns-tz', + 'floating-vue', + 'canvas-confetti', + 'lightweight-charts', + '@injectivelabs/utils', + '@injectivelabs/sdk-ts', + '@injectivelabs/wallet-ts', + '@vueuse/integrations/useQRCode', + ...(isLocalLayer ? [] : additionalDeps) + ], exclude: ['fsevents'] } }) as ViteConfig