Skip to content

Instantly share code, notes, and snippets.

@jaschaio
Created March 29, 2021 14:32
Show Gist options
  • Save jaschaio/321e794e7f8fb15d4bf9dfa0da46656c to your computer and use it in GitHub Desktop.
Save jaschaio/321e794e7f8fb15d4bf9dfa0da46656c to your computer and use it in GitHub Desktop.
<!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>
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;
} )();
{
"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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment