Skip to content

Instantly share code, notes, and snippets.

@jaschaio
Created March 29, 2021 14:32
Show Gist options
  • Select an option

  • Save jaschaio/321e794e7f8fb15d4bf9dfa0da46656c to your computer and use it in GitHub Desktop.

Select an option

Save jaschaio/321e794e7f8fb15d4bf9dfa0da46656c to your computer and use it in GitHub Desktop.

Revisions

  1. jaschaio created this gist Mar 29, 2021.
    13 changes: 13 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="Starter Snowpack App" />
    <title>Starter Snowpack App</title>
    <script type='module' src="/index.js"></script>
    </head>
    <body>
    <h1>Welcome to Snowpack!</h1>
    </body>
    </html>
    19 changes: 19 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import { library, icon } from '@fortawesome/fontawesome-svg-core';

    const getIcon = async ( { icon: iconToFetch } ) => {

    const { [ iconToFetch ]: importedIcon } = await import( `@fortawesome/free-brands-svg-icons/${ iconToFetch }.js` );

    library.add( importedIcon );

    return icon( importedIcon, { classes } ).html

    }

    ( async () => {

    const html = await getIcon( { icon: 'faFacebook' } );

    document.body.innerHTML = html;

    } )();
    19 changes: 19 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    {
    "name": "failed-to-resolve-example",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.35",
    "@fortawesome/free-brands-svg-icons": "^5.15.3"
    },
    "devDependencies": {
    "snowpack": "^3.1.2"
    },
    "scripts": {
    "start": "snowpack dev",
    "build": "snowpack build"
    },
    "author": "",
    "license": "ISC"
    }