最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nuxt.js - Need to tell Nuxt to ignore a folder at build time - Stack Overflow

programmeradmin0浏览0评论

My project has a folder named kaspa that was placed at the root directory. That folder are already been built by external parties so it must be left as is when running pnpm build.

I have set these options on my config file

nitro: {
  esbuild: {
    options: {
      target: 'esnext',
      exclude: ['kaspa/kaspa.js', 'kaspa/kaspa_bg.wasm'],
    },
  },
},

vite: {
  optimizeDeps: {
    include: ['kaspa/kaspa.js'],
    exclude: ['kaspa/kaspa_bg.wasm'],
  },
},

as well as adding a .nuxtconfig file with the same content:

kaspa/kaspa.js
kaspa/kaspa_bg.wasm

But it doesn't work.

Nuxt keeps rebuilding it, and compiled it as .nuxt/dist/server/_nuxt/kaspa-CvShH_pb.js. I don't want this because it replaces the classes to a minified object that causes this kind of error:

object constructor `et` does not match expected class `Resolver` 

class Resolver itself is part of kaspa.js. What can I do to make this work?

EDIT

To make it clear, I've attached a code snipped how kaspa was used in the project; it is consumed inside a pinia store.

import * as kaspa from '~/kaspa/kaspa'

export const useKaspaStore = defineStore('kaspa', () => {
  const rpc = shallowRef<kaspa.RpcClient>()

  const init = async () => {
    await kaspa.default()

    rpc.value = new kaspa.RpcClient({
      encoding: kaspa.Encoding.Borsh,
      networkId: networkId.value,
      resolver: new kaspa.Resolver(),
    })

    await rpc.value.connect()
  }
}

This pinia store are then consumed by a layout.

发布评论

评论列表(0)

  1. 暂无评论