Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to import google fonts with sass #10

Open
snowman opened this issue Apr 2, 2019 · 6 comments
Open

Fail to import google fonts with sass #10

snowman opened this issue Apr 2, 2019 · 6 comments

Comments

@snowman
Copy link

snowman commented Apr 2, 2019

// FILE: vue.config.js
const path = require("path")

module.exports = {
  pluginOptions: {
    ...
    'style-resources-loader': {
      preProcessor: 'sass',
      patterns: [
        path.resolve(__dirname, 'src/assets/styles/main.sass')
      ]
    }
    ...
  }
}
// FILE: main.sass
@import url('https://fonts.googleapis.com/css?family=Karla:400,700|Rubik:400,500,700')

Error:

File to import not found or unreadable: ../assets/styles/url('https://fonts.googleapis.co│
m/css?family=Karla:400,700|Rubik:400,500,700')
@snowman
Copy link
Author

snowman commented Apr 2, 2019

SOLUTION

// FILE: src/assets/styles/base/_typography.sass
@import url('https://fonts.googleapis.com/css?family=Karla:400,700|Rubik:400,500,700')
// FILE: main.sass
@import 'base/typography'

@snowman snowman closed this as completed Apr 2, 2019
@yenshih
Copy link
Owner

yenshih commented Apr 2, 2019

It must be a bug when the loader resolves @import url(). I will fix this. Thanks for reporting.

@danhorton7
Copy link

I am still experiencing the exact same issue as @snowman, moving the type imports to a separate file worked fine.

@yenshih yenshih reopened this Mar 4, 2020
@mihailthebuilder
Copy link

mihailthebuilder commented Nov 19, 2020

It's a problem with sass-resources-loader as well: webpack/webpack#8865 (comment)

@yenshih
Copy link
Owner

yenshih commented Nov 20, 2020

Actually it's not a problem.
Statements like @import url('https://fonts.googleapis.com/css?family=Karla:400,700|Rubik:400,500,700') is not preferred to inject into all style files, they may be imported only once.

@nobi1007
Copy link

Also, moving those url imports from your .scss file to your index.html file should work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants