antfu / purge-icons

🎐 Bundles icons on demand
https://www.npmjs.com/package/purge-icons
MIT License
229 stars 18 forks source link

vite project error #3

Closed xxholly32 closed 3 years ago

xxholly32 commented 3 years ago

when i use your demo in the real environment. it was throw error

Error: connect ECONNREFUSED 151.101.0.133:443
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)

151.101.0.133:443 links to raw.githubusercontent.com ,but it`s unstabled

In your lerna env or npm link , your project node_modules @iconfiy has ths json folder. but not in the real vite project

here is the code

if (source === 'local' || source === 'auto') {
    try {
      debug(`fetching collection "${name}" from local packages`)
      const collection = await import(`@iconify/json/json/${name}.json`)
      cache[name] = collection
      return collection
    }
    catch (e) {
      debug(`error on fetching collection "${name}"`, e)
      if (source === 'local')
        throw e
    }
  }

i cant find a way to fix it. This error came no where ,and take my quite a while. maybe your can fix it. ty

antfu commented 3 years ago

I idea is like if you have @iconify/json installed in your dependencies, it will use it locally. If not, it will try to download the resources online with the collection you actually use. To fix this, you can just install @iconify/json as you devDeps, or maybe bind a Proxy which makes raw.githubusercontent.com stable.

I will update the docs properly soon. Thanks for the feedback.