Using a SASS watcher to keep an eye on every folder and compile them into a single CSS

I'm interested in setting up a folder structure like this:

assets
- scss
  - folder
      file.scss
      anotherfile.scss
      anotherfile.scss
      anotherfile.scss
  - anotherfolder
      file.scss
      anotherfile.scss
      anotherfile.scss
      anotherfile.scss
- css
    main.css

... and compile it all into one main.css. Currently, I'm using npm run scss + node-sass as shown in my package.json file:

{
 "name": "test",
 "version": "1.0.0",
 "description": " ",
 "main": "index.js",
 "scripts": {
   "test": "echo \"Error: no test specified\" && exit 1",
   "scss": "node-sass --watch assets/sass/app.scss assets/css/app.css"
 },
 "license": "ISC",
 "private": true,
 "dependencies": {
   "npm-sass": "^2.2.1"
 }
}

Currently, when I make changes in the subfolders, the main.css is updated along with additional CSS files like css>folder>anotherfile.css. This causes errors because the compiler doesn't recognize variables from vars.scss when I modify scss>folder>anotherfile.scss.

I want to avoid this issue. Is there a way to monitor the entire folder structure but only compile main.scss to main.css when there are changes? Thank you for the help!

Answer â„–1

To change the names of files, with the exception of main.scss, add an underscore before the name. For example, anotherfile.scss would become _anotherfile.scss

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

Encountering an issue while trying to run npm init and the

I am encountering an issue while trying to set up NPM in my project. Every time I attempt to initialize it, I get the following error: C:\Users\work-\Documents\MyWork\Folder\utils>npm init npm ERR! code MODULE_NOT_FOUND npm ...

changes in size in relation to the position of the parent element

Utilizing the transition:scale(1.2) property to conceal a div positioned in the lower left corner of the viewport. Currently, the scaling effect originates from the center as intended: View 'CURRENTLY' on Fiddle I aim to scale it as if the div ...

How to Add a Responsive Inset Transparent Overlay to Images without Using JavaScript?

My goal is to create a unique overlay effect on images of different sizes within a Pinterest-style fluid grid layout. The outer border width and inset 'border gap' will remain consistent, while the images themselves need to dynamically adjust. C ...

Observing the technique in Vue.js 2 does not result in the modification of the isAuth value

Hey, I'm new to Vue.js and I've been working on setting up authentication for a basic site. So far, I have implemented user registration and login functionality. The views are displayed based on the user's authentication status. However, I&a ...

Customize Google Chrome to display a vibrant splash screen instead of a boring white blank page when

"I've been on the lookout for Chrome apps that can help make my screen darker or inverted to reduce eye strain. While I have found some apps that do the job, there's one thing they don't seem to be able to override - the White Blank page. W ...

Exploring the Azure Artifacts npm repository and authentication within Azure Pipelines

Having difficulties with authentication in my application. During the build process in my Azure Pipeline, I use dotnet publish and run npm install. I have configured the .npmrc file to accommodate two registries - one from npm and the other one from Azure ...

Determining whether an npm package was installed locally or globally

Currently setting up Grunt, Node.js, npm, Bower, and grunt-cli on Windows 7. The guide advises me to execute the installation commands with the -g flag for global scope. How can I verify if I indeed used the -g flag during the setup process? Reinstallin ...

What could be the reason for the presence of three pixels of white space below this particular table

My table is supposed to have a fixed height of 146px, but there seems to be an extra row of three pixels at the bottom. I've tried various methods to remove any unwanted spacing or padding, but nothing has worked so far. The only solution I found was ...

"Transforming a static navbar to a fixed position causes the page to jump

Having some difficulty figuring this out. I'm working on a bootstrap navbar that transitions from static to fixed when the user scrolls past the logo at the top. Everything seems to be working fine, except for when the navbar reaches the top, it sudde ...

How can I resize an image to fit at the bottom of the screen, similar to a footer?

Currently, the image is not spanning the entire width of the screen I've looked into various solutions for similar issues, but they always end up aligning the image to the right or left and increasing its size. If anyone has any suggestions, I would ...

Looking to align three divs side by side in the center

My goal is to have three buttons aligned side by side, but I want them center-aligned instead of floated to the left. I have already set the display to inline-block and vertical align to top. div.rotateBtn input { background-image: url(""); margin-l ...

Develop a consistent build process for Lambda Layers within a monorepo utilizing Yarn Workspaces

In our extensive monorepo, we exclusively utilize Yarn Workspaces (without Lerna). Within one of the packages ("workspaces"), we house a collection of third-party NodeJS packages that serve as a shared layer for our Lambda functions, listed as dependencies ...

How can I apply borders to individual columns within a Bootstrap table without affecting the rows?

My attempted solution involved adding th and tfoot. However, I faced issues with applying borders to only the td elements - border was not being applied at the bottom of the table, and the thickness and color of the borders were inconsistent between column ...

The table toggle feature seems to be malfunctioning in Safari, whereas it works perfectly in Chrome

My table includes a td element that serves as a toggle switch, transitioning between 3 states flawlessly in Chrome. However, I am facing issues with its functionality in Safari and seek assistance in rectifying the issue to ensure cross-browser compatibili ...

Angular components are not properly adhering to the specified height and width dimensions for child elements

I seem to be having trouble applying height/width to a child component in angular. Can someone take a look and point out where I may have gone wrong? app.component.html <app-child [width]="10" [height]="10"></app-child> .child.ts import { C ...

Dim the entire website

I am attempting to apply a grey overlay across my entire site when a file is dragged in for upload. The drag event and activation of the grey overlay are functioning correctly, but there are specific areas where it does not work as intended. There seems t ...

Unable to show the name of the chosen file

After customizing the input [type = file], I successfully transformed it into a button with a vibrant green background. Here is the code snippet that enabled this transformation: <style> #file { height:0px; opacity:0; } ...

Attempting to alter the background image through the action of clicking on an image using jQuery, HTML, and CSS

I have created custom weather icons like a sun, cloud, and rainy cloud using Photoshop. My goal is to allow users to click on these icons and change the background image of the website's body. However, despite my efforts, clicking on the images does n ...

What is the method for adjusting the text color in an HTML document?

Is there a way to modify the text color of this statement: You Have Already Earned Credit For This Link? <div id=\"myform\" style=\"visibility: hidden;\"> <font size=2><b>You Have Already Earned ...

"Enhancing the spacing between background images through CSS: A guide to using the repeat property

Looking to design a background with a repeating image using CSS. background: url(../images/bg.PNG) repeat; However, facing an issue where the images are too close together. Any suggestions on how to add padding around each image? ...