当尝试在我的ruby项目中包含sass文件时,出现错误SASS :: syntaxerror未定义变量$ mq-m-max。
我将文件application.css重命名为application.scss,所以这里是我的application.scss:
@import "abstracts/variables";
@import "abstracts/_mixins";
我的文件_variables.scss:
$mq-a: 360px;
$mq-s: 414px;
$mq-t-max: 767px;
$mq-t: 768px;
$mq-m-max: 999px; // 1023px;
$mq-m: 1000px; // 1024px;
$mq-ml-max: 1279px;
$mq-ml: 1280px;
// $mq-l: 1400px; // Not revelant now
$mq-l: 1600px;
$mq-xl: 1920px;
和我的文件_mixins.scss:
@mixin mq($size: m,$max: false) {
@if $size == t {
@if $max {
@media (max-width: $mq-t-max) {
@content;
}
} @else {
@media (min-width: $mq-t) {
@content;
}
}
}
@else if $size == m {
@if $max {
@media (max-width: $mq-m-max) {
@content;
}
} @else {
@media (min-width: $mq-m) {
@content;
}
}
}
和我的gemfile:
ruby '2.6.3'
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','~> 6.0.0'
# Use sqlite3 as the database for active Record
gem 'sqlite3','~> 1.4'
# Use Puma as the app server
gem 'puma','~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails','~> 5'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker','~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks','~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.7'
# Use Redis adapter to run action Cable in production
# gem 'redis','~> 4.0'
# Use active Model has_secure_password
# gem 'bcrypt','~> 3.1.7'
# Use active Storage variant
# gem 'image_processing','~> 1.2'
#Contentful
gem 'contentful','~> 2.14'
#contentful rails
gem 'contentful_rails','~> 0.5.0'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap','>= 1.4.2',require: false
group :development,:test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug',platforms: [:mri,:mingw,:x64_mingw]
end
group :development do
# access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console','>= 3.3.0'
gem 'listen','>= 3.0.5','< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen','~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara','>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]
我不明白为什么它不起作用,在混合之前调用变量。在我的application.scss中,_mixins和_variables的路径运行良好