lit / lit-element

LEGACY REPO. This repository is for maintenance of the legacy LitElement library. The LitElement base class is now part of the Lit library, which is developed in the lit monorepo.
https://lit-element.polymer-project.org
BSD 3-Clause "New" or "Revised" License
4.49k stars 319 forks source link

webpack url-loader and css font-face #1178

Closed tamis-laan closed 2 years ago

tamis-laan commented 3 years ago

I'm using lit-element in combination with webpack. I'm trying to load fonts and use them in my project:

import eot from 'root/node_modules/material-design-icons/iconfont/MaterialIcons-Regular.eot'
import woff2 from 'root/node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2'
import woff from 'root/node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff'
import ttf from 'root/node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf'

export const css_mdi = css`
  @font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url(${unsafeCSS(eot)}); 
    src: local('Material Icons'),
      local('MaterialIcons-Regular'),
      url(${unsafeCSS(woff2)}) format('woff2'),
      url(${unsafeCSS(woff)}) format('woff'),
      url(${unsafeCSS(ttf)}) format('truetype');
  }
`

I'm using webpack url-encoder to encode fonts and images as so:

{
  test: /\.(jpg|jpeg|png|svg|ico|eot|ijmap|ttf|woff|woff2)$/,
  use:{
    loader:'url-loader'
  }
}

I'm not sure why this isn't working, I'm suspecting lit-element but I'm not familier enough to say. So is this the correct way to use webpack, fonts and lit-element? Should this work?

kevinpschaaf commented 2 years ago

Closing due to age. Please re-open with a repro if your issue persists.