SCSS导入失败(Jekyll) [英] SCSS import fails (Jekyll)

查看:211
本文介绍了SCSS导入失败(Jekyll)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在GitHub页面上设置Jekyll.即使在使用bundle exec jekyll serve --safe时,在本地也没有构建/执行警告/错误.但是import命令在GitHub页面上失败.我回来的错误是:

I'm trying to setup Jekyll on GitHub pages. Locally I have no build/execution warnings/errors, even when I use bundle exec jekyll serve --safe. But the import command fails on GitHub pages. The error I'm getting back is:

您的SCSS文件css/main.scss在第49行出现错误:找不到或无法读取的导入文件:基本

Your SCSS file css/main.scss has an error on line 49: File to import not found or unreadable: base

我还没有更改main.scss的内容:

// Import partials from `sass_dir` (defaults to `_sass`)
@import
    "base",
    "layout",
    "syntax-highlighting"
;

_config.yml中显式定义sass_dir变量无济于事.有没有一种方法可以在本地调试scss文件?我尝试使用sass命令,但似乎不适用于scss文件.

Defining the sass_dir variable explicitly in _config.yml doesn't help. Is there a way to debug scss files locally? I have tried using the sass command but it doesn't seem to work with scss files.

我知道问题出在@import部分,因为如果我对其进行评论并在GitHub页面上推送构建不再失败-但我的博客很丑:)

I know that the problem is with the @import part because if I comment it and push the build on GitHub pages no longer fails -- but my blog is ugly :)

注意:我已经尝试了Jekyll 2.1中 SCSS @import中描述的内容但这并没有带我到某个地方.

Note: I have already tried what's described in SCSS @import in Jekyll 2.1 but it didn't get me somewhere.

推荐答案

好,知道了!很简单.

  • Github页面从您的存储库根目录运行:faif.github.io
  • 由于您的_config.yml文件位于/blog中,因此没有看到所有内容都采用默认设置.例如:scss导入的路径为faif.github.io/_sass,并会导致错误,因为您的文件位于faif.github.io/blog/_sass中.
  • Github pages is running from your repository root : faif.github.io
  • as your _config.yml file is in /blog, it doesn't see it an takes default settings for everything. eg : path for scss import, is faif.github.io/_sass and result in an error, because your files are in faif.github.io/blog/_sass.

在根目录下移动_config.yml并调整sass, includes, ...变量.我认为这不是最好的选择,但是如果可以在jekyll 3.1.x中进行配置(文档).

Move _config.yml at the root and tweak sass, includes, ... variables. I don't think it's the best option, but it can certainly be done as nearly everything if configurable in jekyll 3.1.x (documentation).

  • 创建博客存储库
  • 克隆
  • git checkout -b gh-pages,因为项目存储库仅从gh-pages分支发布
  • 在此存储库中复制您的博客文件夹内容
  • 从faif.github.io存储库中删除博客文件夹
  • _config.yml中将baseurl更改为/blog
  • 提交并推送
  • Create a blog repository
  • Clone it
  • git checkout -b gh-pages because project repositories are published from gh-pages branch only
  • Copy your blog folder content in this repository
  • Remove your blog folder from faif.github.io repository
  • Change baseurl to /blog in _config.yml
  • Commit and push

您完成了.

这篇关于SCSS导入失败(Jekyll)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆