Playing Next Lesson In
seconds

Let's Learn AdonisJS 6 #3.10

Easy SVG Icons with Edge Iconify

In This Lesson

We'll learn how we can install and use the edge-iconify package giving us super easy access within our EdgeJS files to any of the SVG icon packages available through Iconify.

Created by
@tomgobich
Published

Join the Discussion 8 comments

Create a free account to join in on the discussion
  1. @cbernard

    Hi Tom, really enjoying the videos. I have a question on this one. As per the documentation I'm using in globals.ts

    import { Edge } from 'edge.js'
    import { edgeIconify, addCollection } from 'edge-iconify'
    import { icons as heroIcons } from '@iconify-json/heroicons'
    
    addCollection(heroIcons)
    
    const edge = Edge.create()
    
    edge.use(edgeIconify)
    
    Copied!

    And then in my home.edge I'm using @svg('heroicons:arrow-left-solid') but I just get raw tag rendered rather than the svg icon. Any ideas?

    Copied!

    1
    1. Responding to cbernard
      @tomgobich

      Hey cbernard! Thank you, I'm happy to hear that! Yeah, so the EdgeJS documentation takes a framework-agnostic approach to describing things. Within AdonisJS, the edge instance has already been created and you'll want to reference the already existing instance when adding your icons.

      Small change, but this should get things working for ya:

      import edge from 'edge.js' // <-- import default export as edge instance
      import { edgeIconify, addCollection } from 'edge-iconify'
      import { icons as heroIcons } from '@iconify-json/heroicons'
      
      addCollection(heroIcons)
      
      edge.use(edgeIconify) // <-- add to that pre-existing instance
      Copied!
      0
      1. Responding to tomgobich
        @cbernard

        Thanks Tom for the speedy reply. I had originally tried that but to no avail. However, I found my issue. It was because the globals.ts was not registered with the preloads in adonisrc.ts. I think that is explained in lesson 3.8, but I must have missed it.

        2
        1. Responding to cbernard
          @tomgobich

          Anytime! Ah - yes, preloads need registered within the preloads array inside the adonisrc.ts file to be used; happy you were able to get your issue figured out!

          If you create your preload file using the Ace CLI's node ace make:preload command, it'll automatically register it within the preloads array for you as well.

          1
  2. @omariqbal
    1
    1. Responding to omariqbal
      @tomgobich

      Hey omariqbal!!

      Just pulled down at the same point you linked to test it out and everything seems to be running and working okay for me. What version of NodeJS are you running? I can double-check everything on that specific version as well. I'm on 20.14 at the moment.

      1
      1. Responding to tomgobich
        @omariqbal

        Thanks for the quick reply.

        It keeps working fine till node @ 21.7.3 but starts breaking at node @ 22.0.0

        1
        1. Responding to omariqbal
          @tomgobich

          Anytime!!

          It appears to be related to an issue in Vite, here: https://github.com/vitejs/vite/issues/17291

          The error seems to be happening during the import of the phIcons, which also shares similar imports to those mentioned within the linked issue. For now, your best bet is to probably use a NodeJS version < 22, sorry!

          I tried updated all dependencies to latest, and the issue still persisted on NodeJS v22, hopefully it'll get fixed up soon!

          1