无法从Jekyll中的sass文件导入变量

玛玛德娃(Mahma Deva)

我有一个variables.scss在我的根目录中保存所有sass变量文件。我想将其导入我的其他scss文件中,以便可以使用以下变量:

@import "/variables.scss";

但是,当我运行项目时,出现以下错误:

转换错误:Jekyll :: Converters :: Scss在转换'assets / css / index.scss'时遇到错误:
找不到要导入的文件或文件不可读:/variables.scss。加载路径:第1行上的C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/minima-2.5.0/_sass

我在做什么错,如何正确导入我的sass变量。这是我的config_.yml文件:

# Welcome to Jekyll!
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that. If you find
# yourself editing this file very often, consider using Jekyll's data files
# feature for the data you need to update frequently.
#
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.

# Site settings
# These are used to personalize your new site. If you look in the HTML files,
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
# You can create any custom variable you would like, and they will be accessible
# in the templates via {{ site.myvariable }}.
title: Project
email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
  Write an awesome description for your new site here. You can edit this
  line in _config.yml. It will appear in your document head meta (for
  Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: jekyllrb
github_username:  jekyll

# Build settings
markdown: kramdown
theme: minima
plugins:
  - jekyll-feed
  - jekyll-paginate-v2

collections:
  posts:
    output: true
    permalink: /releases/:path

permalink: pretty

sass:
  sass_dir: _sass
  style: compressed
future: true 
published: true
# Exclude from processing.
# The following items will not be processed, by default. Create a custom list
# to override the default setting.
# exclude:
#   - Gemfile
#   - Gemfile.lock
#   - node_modules
#   - vendor/bundle/
#   - vendor/cache/
#   - vendor/gems/
#   - vendor/ruby/

############################################################
# Site configuration for the Jekyll 3 Pagination Gem
# The values here represent the defaults if nothing is set
pagination:

  # Site-wide kill switch, disabled here it doesn't run at all 
  enabled: true

  # Set to 'true' to enable pagination debugging. This can be enabled in the site config or only for individual pagination pages
  debug: false

  # The default document collection to paginate if nothing is specified ('posts' is default)
  collection: 'posts'

  # How many objects per paginated page, used to be `paginate` (default: 0, means all)
  per_page: 5

  # The permalink structure for the paginated pages (this can be any level deep)
  permalink: '/page/:num/' # Pages are index.html inside this folder (default)
  #permalink: '/page/:num.html' # Pages are simple html files 
  #permalink: '/page/:num' # Pages are html files, linked jekyll extensionless permalink style.

  # Optional the title format for the paginated pages (supports :title for original page title, :num for pagination page number, :max for total number of pages)
  title: ':title - page :num'

  # Limit how many pagenated pages to create (default: 0, means all)
  limit: 0

  # Optional, defines the field that the posts should be sorted on (omit to default to 'date')
  sort_field: 'date'

  # Optional, sorts the posts in reverse order (omit to default decending or sort_reverse: true)
  sort_reverse: true

  # Optional, the default category to use, omit or just leave this as 'posts' to get a backwards-compatible behavior (all posts)
  category: 'posts'

  # Optional, the default tag to use, omit to disable
  tag: ''

  # Optional, the default locale to use, omit to disable (depends on a field 'locale' to be specified in the posts, 
  # in reality this can be any value, suggested are the Microsoft locale-codes (e.g. en_US, en_GB) or simply the ISO-639 language code )
  locale: '' 

 # Optional,omit or set both before and after to zero to disable. 
 # Controls how the pagination trail for the paginated pages look like. 
  trail: 
    before: 2
    after: 2

  # Optional, the default file extension for generated pages (e.g html, json, xml).
  # Internally this is set to html by default
  extension: html

  # Optional, the default name of the index file for generated pages (e.g. 'index.html')
  # Without file extension
  indexpage: 'index'

############################################################
阿什马罗利

首先,仅使用相对基名来导入:

@import "variables";

// or if you've nested partials
@import "subdirectory/partial_name";

其次,如果您使用的是sassc宝石,请确保至少sassc-2.1.0在捆绑包中使用。(运行bundle show检查)。或者,如果您使用的是已弃用的sassgem,请继续使用它,直到可以升级为止。

最后,确保您的scss局部没有未封闭的括号。


更新

Jekyll希望在配置的文件中找到要导入的局部文件sass_dir_sass默认情况下)。因此,您必须确保该路径_sass/variables.scss在源目录中或您正在使用的theme-gem中都存在。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Jekyll和Sass找不到导入文件或无法读取文件

Heroku部署失败-无法导入Sass文件

无法在React中导入Sass文件

无法将sass变量从一个scss文件导入到另一个

我正在尝试将SASS变量导入我的javascript文件

Python:即使导入了文件,也无法使用其他文件中的变量

(考拉)无法在Sass中编译变量

rails 5.2.0、sass-rails 5.0.7、bootstrap 4.3.1 无法访问 .scss 文件中的 bootstrap 变量

在一处导入所有文件时,sass变量在Ionic-4中不起作用

如何使用 json 文件中的 sass 变量?

使用导入模块中的变量时,SASS'无效的CSS错误'

如何使用其他sass文件中的sass变量

如何使Bootstrap sass变量对另一个导入的sass文件可见?

它无法识别导入文件中的文件

无法将json导入Angular中的变量

Python:无法从初始化文件导入在setUp方法中初始化的全局变量

使用@use 导入 SASS 变量

使用导入文件中的变量执行功能

使用webpack导入目录中的所有sass文件

从Meteor包中公开Sass文件以进行Meteor App导入

Webpack sass loader无法识别全局变量文件

无法使用导入文件中的类

无法导入html中的js文件

将博客导入Jekyll-此加载错误“要求无法加载此类文件”是什么?

SASS变量无法在VueJS应用中呈现正确的结果

VueJS:动态导入(sass)文件(从变量,可能是process.env)

在 Angular 组件中导入 sass 变量文件,最好的方法是什么?

Django从文件导入变量

从多个文件导入变量