Skip to content

CSS preprocessor - font assets outside of src聽#4031

Closed

Description

@awolfe76

This is a question, not a bug report.

I'm looking for a little help when it comes to using a CSS preprocessor. I followed the instructions for Sass and everything works as advertised. 馃憤

My problem is that the framework I'm required to use also includes fonts, and when it imports those fonts it does so like this:

@font-face {
  font-family: "Source Sans Pro";
  font-style: normal;
  font-weight: 400;
  src: url("../fonts/sourcesanspro-regular-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/sourcesanspro-regular-webfont.woff2") format("woff2"), url("../fonts/sourcesanspro-regular-webfont.woff") format("woff"), url("../fonts/sourcesanspro-regular-webfont.ttf") format("truetype"); }

So when I run a build I see
Module not found: Error: You attempted to import ../fonts/sourcesanspro-light-webfont.eot which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.

That all makes sense.


I'm curious to know if you've seen something like this before and have a work around for it. I've tried adding a few extra scripts to copy the fonts directory from node_modules into src but of course that doesn't help because the @font-face is still going outside of src.

I can attempt another workaround by only including the .scss that I want from the framework (excluding the fonts) and downloading the fonts and checking them into my repo in the public directory, but wanted to see if I was missing an obvious solution first.

Thanks!

Activity

  1. Timer commented on Apr 15, 2018

    @Timer
    Contributor

    Sass support will be released in 2.0 (fyi), and the best advice I can give you is just to move your fonts/ folder into src/ -- I'm sorry if this isn't the most terribly helpful answer, but it's our typical response.

    Since you require some path trickery, you might have to do the following:

    src/assets/css/yourcss.css
    src/assets/fonts # the copied fonts
    

    Is there a reason you don't want them in your src/ folder?

  2. SeanFelipe commented on Jan 2, 2019

    @SeanFelipe

    I'm in a similar situation, and first thought was to not have them in the src/ directory since they would seem to be more binary assets than text source code.

  3. locked and limited conversation to collaborators on Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions