using node-sass with several different starting points

I am currently working on a project where my main entry point is structure.scss, and each platform has its own second entry point. Here is the folder structure:

scss/
|
|-- components/                 # Modular Component Files
|   |-- login.scss              # Structure file for Login Module
|
|-- platforms/
|   |-- globals/
|       |-- components/
|           |-- login.scss
|       |-- global-imports.scss
|       |-- base.scss
|   |-- platform1.scss          # Entrypoint for Platform 1
|   |-- platform2.scss          # Entrypoint for Platform 2
|   |-- platform3.scss          # Entrypoint for Platform 3
|
`-- structure.scss              # Primary Entrypoint for all Platforms

Here are my Npm Scripts:

"scripts": {
    "platform": "node-sass --watch --recursive --output-style 'compressed' src/scss/platforms/ -o public_html/inc/assets/css/platforms",
    "structure": "node-sass --watch --recursive --output-style 'compressed' src/scss/style.scss public_html/inc/assets/css/style.css",
    "scss": "npm run platform & npm run structure"
},

I encounter an issue where when I make changes to a file, it tries to compile that file as the entrypoint, resulting in console errors due to missing variables. To resolve this, I have to make unnecessary changes to the correct file every time.

Does anyone have a solution for this problem?

Another issue I face is the inability to overwrite default mixin vars in platforms > globals > components > login.scss from any platform.scss...

Answer №1

After some trial and error, I finally found the solution! To keep things neat, simply monitor the entire scss directory using:

  "scripts": {
    "scss": "node-sass --watch --recursive --output-style 'compressed' src/scss/ -o public_html/css/"
  },

Make sure to prefix any files you don't want to be entry points with an underscore before the file name! For example, _file.scss

_files will still be included when imported but will be disregarded by the watcher.

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 are the steps to configure ESlint and Prettier with the Airbnb style guide for a React Native/JavaScript project (Expo) in VS Code?

I have looked through numerous tutorials on this topic, but I haven't been able to get it to work. In the tutorials, when you run npm install eslint, it usually prompts you in the command line about using a popular style guide. However, this no longer ...

Identifier for md-radio-group

In my Angular 4 Material application, I have a set of radio buttons grouped together: <md-radio-group fxLayout fxLayoutAlign="center center" fxLayoutGap="30px"> <md-radio-button value="1">Date</md-radio-button> <md-radio-butto ...

HTML div feedback container with directional pointer

I've been working on creating a comment box with an arrow using CSS, but I'm facing a particular challenge. My comment box has a white background, and in order to make it stand out, I need to add a border. However, I'm struggling with addin ...

What is the reason for the failure of the require("perf_hooks") function?

My understanding is that "perf_hooks" is a component of Node.js. However, when I run tests with npm test, it fails for me and shows the following error (some file names have been altered): Error: ENOENT: no such file or directory, open 'perf_hooks&apo ...

Adjust image size to maintain consistent dimensions

Is there a way to resize the images so they maintain the same aspect ratio? Currently, all the images are appearing distorted. Here is the HTML code for the card: <div class="container"> <div class="flex-row row"> <div class="col ...

Harness the power of multiple backgrounds with just one CSS style!

I'm exploring a way to incorporate multiple images as backgrounds into my website design. For instance, having a car image on the index page and a notepad image on the about me page. My attempt involved using the following code: body { back ...

What are some ways to utilize symbol fonts such as marvosym within a web browser?

Are you looking to use special LaTeX fonts like \Pluto from marvosym in your web development projects? Wondering how to display this symbol with HTML / JavaScript / CSS without relying on an image? You can download the font from This symbol corresp ...

Implementing dynamic background images in Angular 4 using div placeholders

Is there a way to include a placeholder or default image while waiting for item.imgSrc to load on the screen? <div class="style" *ngFor="let item of array; <div [style.backgroundImage]="url('+ item.imgSrc +')" class="image">< ...

How can scripts communicate with one another through passing arguments?

"scripts": { "dev": "npm run development", "development": "run-something", .... When invoking my script, I use the following command: npm run dev This is a convenient shortcut that executes the standard command npm-run-development. Is there ...

Unable to delete the margin of Material-ui TextField

Having trouble removing the padding around material-ui's TextField component when using styled-components and inline styling. Any solutions to this issue? Interestingly, the inline width property is functioning correctly, unlike the styled-component w ...

Error encountered: "npm ERROR! Unable to retrieve property '0' when using npm version 5.8.0"

When I tried to update my React/Typescript application with the beta version of material-ui using the command npm install material-ui@next, I encountered an error message: npm ERR! Cannot read property '0' of undefined npm ERR! A complete log o ...

Is there a way to automatically refresh the page and empty the input fields after clicking the submit button on the contact form?

My knowledge of PHP and js is limited, so I may require additional guidance in incorporating those codes. Lately, I've been developing a contact form and making good progress. However, I'm struggling with figuring out how to refresh the page or ...

Steps to configure the npm registry exclusively for a particular project

Currently, I am utilizing a private npm registry for one of my npm packages, while also referring to a couple of other packages from the default npm registry. The method I am currently employing involves setting the registry globally using the following co ...

Encountering an error while trying to install gulp using the NPM command

As I embark on setting up a project with Gulp.js, I encountered an error when running the command: npm install gulp --save-dev The errors that popped up were: npm WARN package.json <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfema ...

Ensure that all elements with the :hover event have a text color of #fff in CSS

 Troubleshooting problems with block's child elements during the :hover event. Specifically, I have a pricing block where I want all texts to be of color #fff when hovered over. Currently, when hovering over the <h3> and <p> elements ...

Issue with the visibility of nested dropdown list on the website

I am encountering an issue with a web page I am working on. On the menu bar, there is a button that triggers a dropdown list of components. These components have submenu items as well. Unfortunately, I am struggling to properly display this structure. I ne ...

utilizing the value within the useState function, however, when attempting to utilize it within this.state, the tab switching feature fails

I am struggling to implement tab functionality in a class component. Even though I'm using this.state instead of useState, the tab switching is not working correctly. I have read the following articles but still can't figure it out: http ...

activate the bootstrap popover by double-clicking instead of a single click

Clicking on a certain div triggers a popover to display another div, which works initially. However, once the popover is removed by clicking outside the div, it requires two clicks to trigger the popover again. How can this be fixed so that it always works ...

Tips for positioning and styling submenu on dropdown using CSS

I am facing an issue with my navigation menu in the design. The sub menu is not displaying when hovered. Is there a solution to fix this problem? Could it be due to missing CSS styles? nav ul {list-style-type: none; overflow: hidden; background: #000; p ...

3 Methods for Implementing a Floating Header, Main Content, and Sidebar with Responsive Design

I am following a mobile-first approach with 3 containers that need to be displayed in 3 different layouts as shown in the image below: https://i.sstatic.net/UjKNH.png The closest CSS implementation I have achieved so far is this: HTML: <header>.. ...