Is it not possible to import in SCSS if the variable is equal to the value?

In my project, I am utilizing scss. There is a variable that determines which scss file needs to be imported based on its value.

I attempted the following approach:

$test: 1;

@if $test == 1 {
  @import "./theme1.scss";
}

However, an error message is displayed:

'This at-rule is not allowed here.'

Is there a way to achieve this? If so, what would be the correct method?

Answer №1

It is prohibited to use import directives within control directives or mixins. Although this feature was discussed on sass GitHub, it has not been implemented and will not be for the foreseeable future.

The recommended approach is to directly import your scss file without any conditions.

For more information on this topic, you can refer to the same question discussion here.

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

Inserting a vertical barrier in the midst of the content

I am struggling to create a vertical divider and align the text properly in the top right corner of my screen. https://i.sstatic.net/UqURE.png Currently, I am facing issues with displaying the divider and positioning the text correctly. <div class="r ...

Unable to achieve panel sliding out with jquery

I am attempting to achieve a sliding effect for the gray panel. My goal is to have the entire div (with a gray background) slide out when clicking on "target 1", "target 2", or "target 3" before the other colored panels slide in. Subsequently, when the u ...

Table lines that are indented

I am currently in the process of transforming a standard HTML table into an indented version like this: Is there a way to hide the initial part of the border so that it aligns with the start of the text, even if I can't do it directly in HTML? ...

I aim to utilize JavaScript to capture the constantly changing font color that is randomly generated

Is there a way to extract the font color from a table element? #FF0000 For example, it could be #568000 etc.. Here's my table <table class="mytable"> <th class=vertical bgcolor=#C0C0C0 align=center> <font color=#FF0000 size= ...

Using Angular 8 to Pass Form Data to Another Component via a Service

Is there a way to send all the Formgroup data as a Service in Angular to Another Component without using ControlValueAccessor? I want the receiver to automatically receive the value data whenever someone enters information on a form. I am attempting to mo ...

Learn the effective way to style ul elements within @mui/material/Menu using CSS

When the button is clicked, I want to apply the following styles to the ul: &.MuiList-root { padding-top: 0px; padding-bottom: 0px; } View the issue in action on this live sandbox: https://codesandbox.io/s/react-typescript-forked-tyd8n8?fil ...

Center the text on a Bootstrap progress bar regardless of the progress level

In the image below, notice how the text is currently centered in the middle of the progress bars' progress. Is there a way to have this text 'overlap' the progress, stand out, and be centered across the entire width while still showing the p ...

Angular: Simplifying nested array filtering

I'm trying to customize my sidebar menu by hiding certain paths based on the user's role. Here are some example routes: export const ROUTES: RouteInfo[] = [ { path: '/overview', title: 'Overview', type: 'li ...

Step-by-step guide for implementing Angular on a production server with the latest universal server rendering feature in angular-cli

I have successfully deployed my Angular application on Azure Server using angular-cli. By running the command ng build --prod --aot and transferring files from the /dist folder to the root website folder, everything is working perfectly! To address SEO c ...

use jquery to dynamically switch CSS class on navigation with animated arrows

Looking to update arrows to display a right arrow when the parent list item has the .active class. Here is the jQuery code: jQuery(function(){ initAccordion(); }); function initAccordion() { jQuery('.accordion').slideAccordion({ opener ...

Achieving successful functionality with position:relative in IE9

Having difficulty with the position: relative property in IE9. Check out this demo for reference: <div style="overflow:scroll;height:120px;"> <table id="table" width="100%"> <tr style="position:relative;background-color:#1b72a4;"> ...

What is the best approach for retrieving Google API responses - accessing them directly from the frontend or routing through the backend first?

Currently, I am in search of the optimal location to make Google API requests. Given that Google Maps is utilized in the front end, we have the option to directly call the distance API service from there. However, we also have the choice to access these se ...

The user interface of an Angular application may vary depending on whether it is running in a local development

In my development environment, I am currently utilizing Angular 5 and Node.js. Interestingly enough, I have noticed that the appearance of my local setup is distinct from the one deployed via DockerCloud. Below is my package.json { "name": "web", ...

Hover over elements in jQuery to smoothly transition them from one class to another

Is it possible to achieve this? For example: .class1{ background-image:(whatever.jpg) color: #fff; } .class2{ background-image:(whatever2.jpg) color: #999; } Can I create a fade effect for all elements with class1 to class2 when the mouse hover ...

Using AJAX to refresh a div upon submitting a form, instead of reloading the entire page

My SQL database generates a table that remains hidden until the search button is clicked to display the results. I want to use ajax to update the table without refreshing the entire page. Currently, when the page refreshes, the table reverts back to being ...

The element's height of 100% falls short of reaching the bottom of its containing element

I have searched through numerous questions, but I am unable to find a solution. Could someone kindly check this link and help me understand why the sidebar is not reaching the bottom of the content div: Using Javascript is not an option for me in this cas ...

Can you explain the significance of the `?` symbol before an object attribute? And why is my TypeScript file not recognizing it?

I have always utilized this particular behavior in Angular using the *ngIf directive when dealing with an object that could potentially be undefined or not the required object. <div *ngIf="object?.foo"> ... </div> Although I know that this ...

Enhance your SVG with a stylish border by adding a decorative

Is there a way to add a blue or black border that follows the curve of an SVG used as a divider? <svg width="100%" height="96px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" prese ...

Adjust the tabs to fit perfectly within the container

I am currently facing an issue with my navigation bar. I have placed the <nav> tags within a container set to 100% width. However, when I adjust the height of the container by a certain percentage, the <ul> & <li> elements in the nav ...

Difficulty in aligning Grid elements in Material UI version 5

Strange enough, the MUI5 Grid is displaying unexpected spacing behavior. Instead of providing proper spacing between items and containers, it seems to be causing them to overlap. To see a live example, visit: https://codesandbox.io/s/green-worker-z44vds? ...