`Ineffective Sass import within asset pipeline``

Within our Rails 3.2 app, I've implemented Sass imports to manage the majority of our styles. The structure of my application.css.scss file is as follows:

application.css

/*
 *= require_self
 *= require_tree ./vendor
 *= require admin
 */

admin.css.scss

// Reset
@import "global/reset";

// General Variables
@import "admin/general/_variables";

// Main Elements
@import "admin/general/_typography";

// Layout
@import "global/_layout";
@import "admin/general/_gridset";

// Modules
@import "admin/modules/_table";
@import "admin/modules/_forms";
@import "admin/modules/_buttons";

// Styles
@import "admin/_style-clean";
@import "admin/_style-images";

// Features
@import "admin/features/features";

Error message: Sass::SyntaxError - Undefined variable: "$body-bg". (in /var/www/apps/dev_wbs/releases/20130624191222/app/assets/stylesheets/admin/_style-clean.css.scss)

The _variables.css.scss file that is imported contains $body-bg, which is used in _style-clean.css.scss

Initially, I wrote the code in Sass syntax, but encountered Sass::SyntaxError - Undefined variable: "$body-bg" whenever we deployed to the dev server. The $body-bg variable is defined in the variables file, yet the error specifically points to the _style-clean.scss file. I attempted to manually add the variable to the style-clean file, only to face another variable error related to the typography file, despite it being declared before style-clean. This led me to suspect that the assets are being pre-compiled and then combined.

Although I prefer using Sass syntax, both scss and sass versions are yielding variable errors.

Currently, all individual files follow the naming convention: _variables.css.scss.

Any assistance on resolving this issue would be greatly appreciated!

Answer №1

The asset pipeline depends on the application.css file to specify which files to include. Converting it to SASS might disrupt this functionality.

In addition, the application.css file in your project must indicate to Ruby where to locate files:

/*
 * This is a manifest file that will be compiled into application.css, containing all the files
 * listed below.
 *
 * Any CSS and SCSS files within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You can add application-wide styles to this file, which will be at the top of the
 * compiled file, but it's generally recommended to create a new file for each style scope.
 *
 *= require_self
 *= require_tree .
 */

If you save the code from your question in a new file named global.css.scss and recreate the application.css file in the /app/assets/stylesheets/ directory, you should be able to proceed smoothly with the provided code and SASS styles too.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to limit the length of text in a div if it surpasses a

As I work on a website, users have the ability to add headings to different sections of a page. For example: M11-001 - loss of container and goods from Manchester Some headings can be quite detailed, but in reality, only the first few words are needed to ...

Interference in the output of .innerHTML leads to disruption

I have been working on a feature to display a calculated price based on the selected quantity for each individual product. I attempted to duplicate the code and modify variable names, but encountered issues with the increase/decrease buttons triggering mul ...

Issue with Angular / SCSS where animation is not being executed on the specified element

I have created a post component with a comment section. However, when I click on the comments, I want them to display smoothly with a nice animation effect. Even though I have added the necessary code for animations, it doesn't seem to work as expecte ...

Tooltip remains visible even after formatting in highcharts

I have successfully hidden the datalabels with 0 values by formatting them. However, after formatting the tooltips for 0 valued data in a pie chart, there is an issue where hovering over the 0 valued portion shows a white box as shown in the picture. I hav ...

Is the ID selector the quickest method in jQuery and CSS?

Which is the optimal choice in jQuery/javascript for speed? $('#myID .myClass') or $('.myClass') What is the preferred option to utilize in CSS? #myID .myClass{} or .myClass{} In hindsight, I realize my explanation was insuffici ...

HTML: attempting to align a quote image next to some text within the page

I want to add a quote to my website, but I'm having trouble positioning it correctly. https://example.com/quote-image.png Every time I try to adjust the position of the quote image, it moves when I zoom out. https://example.com/background.png I attem ...

Is there a way to address this scrollbar issue without relying on HTML?

Currently, I am working on a website where the only customization allowed is related to CSS. While I've been able to make progress, I've encountered an issue with the scrollbar placement. The scrollbar is extending beyond the boundaries of the di ...

Unable to establish connection with internal API using Rails, RSpec and Capybara

When creating a basic Rails app, I decided to refactor it in order to offload heavy processing tasks to an external service like iron.io. This 'worker' handles the heavy lifting. In the refactoring process, I developed a Grape API that allows th ...

I'm having an issue with my progress bar in ReactJS - it seems to move when I scroll the window instead of

My code includes a progress bar that works fine - it shows a movable progress bar when the window is scrolled. However, I want the progress bar to move when scrolling inside my div, not on the entire window. I am currently using jQuery for this functionali ...

Struggling to change h2 style on WordPress?

In a WordPress page, I create three heading texts and adjust the CSS when the screen width is less than 820px. Here is the code snippet: <h1 class="block-h1">Heading 1</h1> <h2 class="block-h2">Heading 2</h2> <h3 class="block-h3 ...

Checking parameters from two forms that are both associated with the same model in Rails

Recently, a new feature was added to the system - a phone and sim checker. Users are required to input their phone number into the first form. If the phone number is found in the database, a message indicating this is displayed. Otherwise, the form switche ...

Personalizing the dimensions of audio.js

I recently integrated the audio.js plugin into my website. I've added the necessary code to the header.php file located in the includes folder. <script src="audio/audiojs/audio.min.js"></script> While the player appears correctly on othe ...

What could be causing the font of the background text to change when CSS3 animation is applied?

Have you ever noticed a font style change in the background text when applying CSS3 animations for opacity and scale transforms? I have some text content on my page, including a "Click me" link that triggers a popup with a CSS3 animation. However, I'v ...

What is the best way to position a background image at the top of a div without overlapping the

I have this HTML code: <div class="page"> <div id="header"> ... </div> </div> Below is my CSS: .page { width: 1028px; background-color:#103250; margin-left: auto; margin-right: auto; } ...

Personalize the material design datatable checkbox option

Recently, I delved into the world of material-ui design in conjunction with ReactJS. However, I have encountered a roadblock while attempting to customize the style of a checkbox that is being displayed under the <TableRow /> component. (Check out th ...

Trouble with the query waypoints extension in a simple demonstration

Can anyone help me figure out why the basic example from the waypoints plugin isn't working for me? Here's a link to the jsfiddle I created: http://jsfiddle.net/ZA8bd/2/ CSS .block1 { margin-top:30px; width: 400px; background: red; ...

How to Position Icon on the Right Side of an Input Field using CSS

Is there a way to position the magnifying glass icon to the right side of my input field? Link to my Fiddle. @import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css"); body { margin: 30px; } .search { position: relative; ...

How to create space between elements in CSS without using margin or padding?

Recently, I stumbled upon a fascinating website while working on my own CSS grid project: I am curious to know how it was achieved. The Portfolio elements on the website have space between them without any visible margins or paddings that I could identify ...

Position several elements in alignment within Bootstrap columns on a single row

Looking for a way to align multiple items horizontally across two columns within a row in Bootstrap? Check out the sample HTML code below: <div class="container"> <div class="row"> <div class="col-sm-6"> <h1>Short Hea ...

Tips for achieving a static background image while allowing scrolling on a webpage in asp.net

I am struggling to implement this on my website. The background image needs to be fixed while the content of the webpage should scroll in asp.net <head runat="server"> <title></title> <style type="text/css"> body { backgr ...